鍍金池/ 問(wèn)答/HTML/ EasyUI HTML頁(yè)面的 <select> 標(biāo)簽用作 combo

EasyUI HTML頁(yè)面的 <select> 標(biāo)簽用作 combobox,怎樣獲取到選中項(xiàng)的值?

<!--貼上html代碼--> 
<select id="ddlState" name="ddlState" class="easyui-combobox" data-options="panelHeight:45,editable:false" style="width: 80px;">
    <option value="0">正常</option>
    <option value="1">下架</option>
</select>

//在網(wǎng)上找到了一種方法,但有問(wèn)題
    function a() {
        var itemState = document.getElementById("ddlState");
        var index = itemState.selectedIndex;
        State = itemState.options[index].value;
        alert("state:" + State);
        alert("index:" + index)
    }
回答
編輯回答
真難過(guò)
$("#ddlState").combobox('getValue');//獲取value值
$("#ddlState").combobox('getText');//獲取text值

你試試這兩個(gè),我用的input元素創(chuàng)建的combobox,是可以的

2018年7月29日 04:15