Home > Article > Web Front-end > jQuery method to loop through child nodes and get values_jquery
The example in this article describes how jQuery loops through child nodes and obtains values. Share it with everyone for your reference, the details are as follows:
Html code part:
<div class="left_tree_ad_btn_container"> <ul> <li class="tree_ad_btn_bg"><img src="/images/insurance/3lianad_small.jpg" /> </li> </ul> <ul> <li class="tree_ad_btn_bg have_bg"><img src="/images/insurance/3lianad_small.jpg" /></li> </ul> <ul> <li class="tree_ad_btn_bg"><img src="/images/insurance/3lianad_small.jpg" /></li> </ul> </div>
JS code part:
var arrUl = jQuery(".left_tree_ad_btn_container > ul"); jQuery.each(arrUl, function(){ alert(jQuery(this).find("img").attr("src")); alert(jQuery(this).find("li").attr("class")); });
Readers who are interested in more jQuery-related content can check out the special topics on this site: "JQuery traversal algorithm and skills summary", "jQuery table (table) operation skills summary" , "Summary of jQuery drag effects and techniques", "Summary of jQuery extension techniques", "Summary of jQuery common classic special effects", "jQuery animation and special effects usage summary", "jquery selector usage summary" and "jQuery common plug-ins and usage summary"
I hope this article will be helpful to everyone in jQuery programming.