2015年9月3日
# 2015年9月3日
each()
: 遍历一个jQuery对象,为每个匹配元素执行一个函数。 eq(index)
: 匹配指定的元素。
标签切换
HTML:
<ul id="tabsecond">
<li class="tabin">Menu One</li>
<li>Menu two </li>
<li>Menu Three</li>
</ul>
<div id="contentsecond">
<div id="realcontent">
<div></div>
</div>
</div>
jQuery:
$("#tabsecond li").each(function(index) {
$(this).click(function(){
$("#tabsecond li.tabin").removeClass("tabin");
$(this).addClass("tabin");
})
})
<br/>
是更长远的使用方式。HTML 标签对大小写不敏感。
Last updated
Was this helpful?