## 下面介绍一种进行点击操作的方法 ![](https://img.kancloud.cn/77/e3/77e39a594981a42d8e24b494599f7100_1920x1048.png) ``` <button class="cx-button-s cx-bg-black gengduolanmu cx-hidden cx-show-l cx-bor-ra cx-click" data-type="gengduolanmu" data-title="请选择栏目" data-cid="#cx-cixi">> 更多栏目</button> ``` * 写上类 `cx-click` 写上`data-type="gengduolanmu"` 这个data-type的属性是必须要写上的,它的值为方法名,我这里写了`data-title="请选择栏目" data-cid="#cx-cixi"`这两个属性到时候可以用到的, * 在js文件中写上了如下代码: ``` layui.define(['layer', 'form','element','carousel','util','laydate','laytpl','laypage'], function(exports) { let $ = layui.jquery, layer = layui.layer, layelement = layui.element, laycarousel = layui.carousel, layutil = layui.util, layform = layui.form, laytpl = layui.laytpl, laydate = layui.laydate, laypage = layui.laypage; let see = { gengduolanmu:function (o) { let d = $(o).data(); //{type:"gengduolanmu",title:"请选择栏目",cid:"#cx-cixi"} } } $('body').on('click','.cx-click',function () { let a = $(this), b = a.data('type'); see[b] ? see[b].call(this, a) : "" }); exports('app', {}); }) ``` * layui.define(['layer', 'form','element','carousel','util','laydate','laytpl','laypage'], function(exports) {}),这里是定义了layui的相关js模块,详情参照[layui文档](https://www.layui.com/doc/element/form.html) * `d`的值为`{type:"gengduolanmu",title:"请选择栏目",cid:"#cx-cixi"}` * 这些写上了即可在你需要进行点击操作的dom上加上类`cx-click` `data-type='方法名'`,然后在see里写上方法名就可以进行点击操作了