首先,www.887551.com要告诉大家一个残酷的现实,那就是layui对按钮没有提供点击事件的支持…
这里的点击事件是指单纯的点击事件,而不是提交事件,或者是数据表格中内嵌的button,对于这两者,layui是有lay-submit和lay-event这个属性进行支持的,所以这里只能使用最原始的js和jq进行监听点击事件。
第一种,js的监听:
<button class="layui-icon layui-icon-export" id="withexport"></button>
$(document).on('click',"#withexport",function(){ layer.msg("按钮点击"); });
第二种,jquery的监听:
<button class="layui-icon layui-icon-export" id="withexport"></button>
$("#withexport").click(function(){ layer.msg("点击事件"); });
黄山市民网:https://www.huangshanshimin.com/