easyui-combobox 选中触发事件 onChange

时间:2021-07-02 16:22:25   收藏:0   阅读:0
项目中碰到使用easyui-combobox下拉框,但是在选择时候要触发选中事件,网上找了好多贴吧,好多都是给出这样解决方式

$("#id").combobox({  
   onSelect: function () {   

    }  
});

但是,使用的是<input>标记创建组合框,试了了很多次上面的方法好像都不管用

另一种方法;
<input class="easyui-combobox" id="scenes" name="scenes" editable="false" style="width: 150px"
data-options="valueField: ‘value‘,textField: ‘label‘,data: [{label: ‘场景一‘,value: ‘1‘},{ label: ‘场景二‘,value: ‘2‘}],panelHeight:‘auto‘,onChange:function(){changeScenes();}" />

在js中写一个changeScenes()方法

 

获取单个值的:getValue

获取多选的值:getValues function changeScenes(){   var text = $("#scenes").combobox("getValues");   console.log(text); }

 

easyui文档:https://www.jeasyui.net/plugins/170.html

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!