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>


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


jQuery循环判断点击的那个节点

你可能感兴趣的:(jquery,element,click,乔乐共享)