绑定点击事件 传参

'<button class="indexType active" onclick=typeFn(this) data-type="1">全部</button>'+
'<button class="indexType" onclick=typeFn(this) data-type="2">今日</button>'+
'<button class="indexType" onclick=typeFn(this) data-type="3">昨日</button>'+

 

function typeFn(that){
indexType = $(that).attr("data-type");
$(".indexType").removeClass("active")
$(that).addClass("active")
console.log(indexType);
}

posted on 2019-02-15 10:38  再胖十斤就好  阅读(1429)  评论(0编辑  收藏  举报

导航