jQ动态获取option值

方式一:

 1 <select id="select">
 2     <option value="0">请选择</option>
 3     <option value="1">One</option>
 4     <option value="2">Two</option>
 5 </select>
 6 
 7 <script src="static/js/jquery-1.11.0.min.js" type="text/JavaScript"></script>
 8 <script language="javascript" type="text/javascript">
 9     $('#select').on('change', function() {
10         console.log( this.value );
11     })
12 </script>

方式二:

 1 <select id="tableType" name="tableType" onchange="getTableType();">
 2     <option value="1">年报</option>
 3     <option value="2">半年报</option>
 4     <option value="3">季报</option>
 5     <option value="4">月报</option>
 6 </select>
 7 
 8 
 9 <script src="static/js/jquery-1.11.0.min.js" type="text/JavaScript"></script>
10 <script language="javascript" type="text/javascript">
11     function getTableType(){
12         var value=$("#tableType").val();
13         console.log(value);
14     };
15 </script>

 

posted @ 2020-09-01 10:58  coderjim  阅读(837)  评论(0编辑  收藏  举报

更多知识请点击——

www.7017online.xyz