Home > Web Front-end > JS Tutorial > body text

jQuery method to loop through child nodes and get values_jquery

WBOY
Release: 2016-05-16 15:05:43
Original
2127 people have browsed it

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>

Copy after login

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"));
});

Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template