jQuery children from jQuery selected object?
So here is code what I have.
var template = $("#instance > .template");
$("#instance-" + country + " > .content > .stats > .map > .template").before(function() {
var temp = template.clone();
//ho开发者_StackOverflow中文版w to select descendant?
temp.children(".amount-all").html(json.services[service].total);
return temp;
});
Do I need to do like this:
temp.children(".amount-all").children("blala").children("blalalala").html("blala");
Or is there other, easier way?
You can use .find()
to get decendants that match the selector at any level (as opposed to looking at just immediate children like .children()
does), like this:
temp.find(".amount-all").html(json.services[service].total);
精彩评论