绑定点击事件 传参

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

原文地址:https://www.cnblogs.com/weiwentaweb/p/10382223.html