layui select下拉框选择事件
程序员文章站
2022-07-13 12:18:50
...
html:
<div class="layui-input-inline layui-show-xs-block" style="margin-left: 25%">
<select lay-filter="kuang" lay-verify="required" id="select_id" name="condition">
<option value="">按类型进行排序</option>
<option name="da" value="3">大</option>
<option name="zhong" value="2">中</option>
<option name="xiao" value="1">小</option>
</select>
</div>
js:
layui.use(['layer', 'jquery', 'form'], function () {
var layer = layui.layer,
$ = layui.jquery,
form = layui.form;
form.on('select(kuang)', function (data) {
// console.log(data);
if (data.value == 1) {
console.log(1);
} else if (data.value == 2) {
console.log(2);
} else if (data.value == 3) {
console.log(3);
}
});
});