js和jq选择相关
原生js
| 1 | 
 | 
| 1 | if(mySelect.options[1].selected == true){ | 
JQ部分
1.判断option是否被选中
| 1 | $("#id").is(":checked")//为false时是未被选中的,为true时是被选中 | 
2.获取select选中的值
| 1 | $("#mySelect option:selected").text() | 
3.获取select选中的索引
| 1 | $("#mySelect").get(0).selectedindex | 
4.添加option
| 1 | $("#mySelect").append("<option value="+value+">"+text+"<option>"); | 
5.删除option
| 1 | $("#myOption").remove() | 
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
 Comment










