开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜