我将如何使用this.something
每个函数的外部
$(function(){
var json = '{ "list": [ { "something": "my string", "stuff": "this" }, { "something": "string of me", "stuff": that } ] }';
$.getJSON(json, function (data) {
$.each(data.list, function() {
$( "#someclassthatdoesntmatter" ).append("<div class='somediv'>"+something+"</div>")
//here this.something is defined
});
});
//here I want to alert a 'something' on clicking the 'somediv' which it appended to
//didn't come further than:
//$(document).on('click', '#somediv',function(){
// alert(???);
// });
});
我该怎么做?
提前致谢。