layui获取select下拉框选中的value和text

layui获取text和value的方法

<form class="layui-form" action="">
        <div class="layui-inline" >
             <div class="layui-input-inline" >
               <select name="modules" lay-verify="required" lay-search="" lay-filter="test" id="CoalSelect"></select>
             </div>
        </div>
 </form>
  layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            ,layer = layui.layer
        form.on('select(test)', function (data) {
            coalName = data.elem[data.elem.selectedIndex].text;//获取选中值的text
            coalCode = data.value;//获取选中值的value
           
        });
  }) 

 

你可能感兴趣的