Home >Web Front-end >JS Tutorial >jQuery method to loop through child nodes and get values_jquery

jQuery method to loop through child nodes and get values_jquery

WBOY
WBOYOriginal
2016-05-16 15:05:432141browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn