layui tags.js 的使用

1 <div class="layui-btn-container tag" lay-filter="tags">
2    <script type="text/html" template lay-url="/admin/exam/getExamReasonList" lay-done="layui.data.done(d);">
4        {{# layui.each(layui.data('reason').reasoncontent,function(index,item){ }}
5            <button lay-id="{{index}}" type="button" class="tag-item">{{item}}</button>
6        {{# }) }}
7    </script>
8 </div>
 1 var that = this;
2 var reasonContent = [];
3 layui.use(['tag'],1)">function () {
 4     var tag = layui.tag;
 5     tag.render("tags");
6   tag.on('click(tags)',1)"> (data) { 7 var b = data.elem.context.attributes[2].value; 8 var a = b.indexOf('layui-btn-primary'); 9 var rContent = this.innerText; if (a != -1) { //选中 10 data.elem.context.classList.remove("layui-btn-primary"11 if (rContent == '其他原因'12 that.otherReason(a); 13 } else { 14 reasonContent.push(rContent); 15 } 16 } 17 不选中 18 data.elem.context.classList.add("layui-btn-primary"19 reasonContent.remove(rContent); 20 21 that.otherReason(a); 22 } 23 } 24 )}
 1 其他原因
 2     var otherReason =  3         if (data != -1 4              5             let newItem = document.createElement('input' 6             newItem.className = 'layui-input';
 7             newItem.id = 'otherInput' 8             newItem.name = 'otherInput' 9             newItem.setAttribute("placeholder","请输入其他原因"10             newItem.setAttribute("lay-verify","required"11              newItem.innerHTML = html;
12             $('#content').append(newItem);
13         } 14             15             $('#otherInput').remove();
16 17     };

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...