我有一个多选下拉菜单,我试图从所选选项的标签中获取完整的文本。
<select role=select multiple= aria-multiselectable=true class=editable inline-edit-cell ui-widget-content ui-corner-all style=display: none;>
<option value=1 label="UNIVERSAL (aa)"></option>
<option value=2 label="UNIVERSAL (bb)"></option>
<option value=3 label="UNIVERSAL (ccc)"></option>
<option value=4 label="UNIVERSAL Without DT"></option>
</select>
{name:"license", id :"qqq", label:"License", width:"400",editrules: true, edittype:"select",Overflow: "visible",
editoptions: {
dataInit: function (elem) {
$(elem).multiselect({
includeSelectAllOption: true,
enableFiltering: true,
maxWidth: 400, //'auto',
maxHeight: 135,
multiselect:true,
selectedList: 3,
noneSelectedText: "Please select",
onChange: function() {
var selected = this.$select.val();
var selectTxt = $('select option:selected').prop('label');
console.log("selectTxt "+selectTxt );
return ;
},
});
$(elem).multiselect('dataprovider',platdata);
},
在这里,selectTxt得到的是UNIVERSAL
,它应该是UNIVERSAL (aa)
。
2条答案
按热度按时间rbl8hiat1#
onchange
函数返回属性value
,并使用该值作为索引,我可以访问第n个选项并获得label
。dba5bblo2#