如何从列表框中获取选定的索引值

时间:2014-04-24 11:10:24

标签: javascript jquery html5

这是我定制的DropDownList的代码:

<script type="text/javascript">
      $(document).ready(function () {                
       var source = [ "Alappuzha","Eranakulam","Idukki" ];
           // Create a DropDownList
          $("#Widget").jqxDropDownList({autoOpen: true, source: source, selectedIndex: 1, width: '241', height: '30'});
             });
 </script>

  <div id='Widget' >
  </div>

如何使用javascript从上面的列表框中获取所选索引值?

1 个答案:

答案 0 :(得分:2)

您可以使用jqxDropDownList小部件的API:

var selectedIndex = $('#Widget').jqxDropDownList('selectedIndex');