【Layui】formSelects下拉多选框取值
程序员文章站
2022-03-09 13:32:31
...
<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'); // ["上海","深圳"]
上一篇: ACGAN代码——阅读记录