使用jquery 实现标签的切换:
话不多说上代码
html:
<div class = "btn-box" id = "caseBtn">
<div ktype = "0" class = "btn active">第一个</div>
<div ktype = "1" class = "btn ">第二个</div>
</div>
js:
$( '#caseBtn .btn' ).on( 'click', function () {
var type = $( this ).attr( 'ktype' );
if(type =="0"){//点击第一个事件
}else if(type =="1"){//点击第二个事件
}
//修改选择样式
$( this ).addClass( 'active' ).siblings().removeClass( 'active' );
} )

版权声明:本文为a843013383原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。