例子,jquery循环判断指定节点是否点击了。
<div class="three_ad_container">
<div class="main_ad_container"><img src="/images/insurance/3lianad.jpg" /></div>
<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>
</div>
<script>
jQuery(".left_tree_ad_btn_container > ul > li").click(function(){
jQuery(".have_bg").removeClass("have_bg");
var objLi = jQuery(this);
objLi.attr("class", "tree_ad_btn_bg have_bg");
jQuery.each(jQuery(".left_tree_ad_btn_container > ul > li"), function(index, value){
if(jQuery(this).attr("class") == objLi.attr("class")){
alert(index);
// jQuery(".main_ad_container > img").attr("src", "/images/insurance/01_bg.png");
}
});
});
</script>