<link rel="stylesheet" href="formSelects-v4.css" /> <script src="layui.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> //全局定义一次, 加载formSelects layui.config({ base: '../src/' //此处路径请自行处理, 可以使用绝对路径 }).extend({ formSelects: 'formSelects-v4' }); //加载模块 layui.use(['jquery', 'formSelects'], function(){ var formSelects = layui.formSelects; }); </script>
取值:
//1.获取选中值 var formSelects = layui.formSelects; formSelects.value('select1'); // [{"name":"上海","val":"2"},{"name":"深圳","val":"4"}] formSelects.value('select1', 'all'); // [{"name":"上海","val":"2"},{"name":"深圳","val":"4"}] formSelects.value('select1', 'val'); // ["2","4"] formSelects.value('select1', 'valStr'); // 2,4 字符串 formSelects.value('select1', 'name'); // ["上海","深圳"] ———————————————— 版权声明:本文为CSDN博主「K1nney」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/wkw1598727534/article/details/101288264