微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐