1.点击span 使span的class属性发生变化class="btn btn-large btn-primary"------ btn-primary这是引入样式2.原代码 <div id="myTab" class="pull-right"> <a href="#listView" data-toggle="tab">
<span class="btn btn-large" ><i class="icon-list"></i></span></a>
<a href="#blockView" data-toggle="tab">
<span class="btn btn-large btn-primary"><i class="icon-th-large"> </i></span></a>
</div>3.目前写成这样就是不生效 <jsp:include page="/static/common/cart_js.jsp"/>
<script type="text/javascript">
$("span").each(function(i){ if(i==0){
$("#listView span").on("click",function(){
$(this).addClass("btn btn-large");
})
}else{
$("#blockView span").on("click",function(){
$(this).addClass("btn btn-large btn-primary");
})
}
});
</script>4.网页效果图求大神帮忙
1 回答
慕码人8056858
TA贡献1803条经验 获得超6个赞
$("span").each(function(i){ $("#myTab span.btn").click(function(){ $("span").removeClass("btn-primary"); $(this).addClass("btn-primary"); }) });
添加回答
举报
0/150
提交
取消