1. $('#select_id').change(function(){//code...});
2. var checkText=$('#select_id').find('option:selected').text();
3. var checkValue=$('#select_id').val();
4. var checkIndex=$('#select_id ').get(0).selectedIndex;
5. var maxIndex=$('#select_id option:last').attr('index');
jQuery设置Select选择的Text和Value:
语法解释:
1. $('#select_id ').get(0).selectedIndex=1;
2. $('#select_id ').val(4);
3. $('#select_id option[text='jQuery']').attr('selected', true);
jQuery添加/删除Select的Option项:
语法解释:
1. $('#select_id').append('<option value='Value'>Text</option>');
jQuery textbox select checkbox radio 取值,设置值
最新推荐文章于 2021-02-17 01:12:04 发布
本文介绍了如何使用jQuery来操作HTML中的Select元素,包括获取和设置选定的文本、值和索引,以及如何添加和删除Select选项。

8705

被折叠的 条评论
为什么被折叠?



