获取Select :
获取select 选中的 text :
$("#sid").find("option:selected").text(); 获取select选中的 value:
$("#sid").val(); 获取select选中的索引:
$("#sid").get(0).selectedIndex; 设置select:
设置select 选中的索引:
$("#sid").get(0).selectedIndex=index;//index为索引值 设置select 选中的value:
$("#sid").attr("value","Normal“);
$("#sid").val("Normal");
$("#sid").get(0).value = value; 设置select 选中的text:
var count=$("#sidoption").length;
for(var i=0;i<count;i++)
{ if($("#sid").get(0).options[i].text == text)
{
$("#sid").get(0).options[i].selected = true; break;
}
} $("#select_id option[text='jQuery']").attr("selected", true); 设置select option项: $("#select_id").append("<option value='Value'>Text</option>"); //添加一项option
$("#select_id").prepend("<option value='0'>请选择</option>"); //在前面插入一项option
$("#select_id option:last").remove(); //删除索引值最大的Option
$("#select_id option[index='0']").remove();//删除索引值为0的Option
$("#select_id option[value='3']").remove(); //删除值为3的Option
$("#select_id option[text='4']").remove(); //删除TEXT值为4的Option 清空 Select :
$("#sid").empty(); 获取radio的值:
<script language="javascript">
$(function() {
$("#Button1").click(function() {
var r = $("input:checked").attr("id");
alert(r); r = $(":radio:checked").attr("id");
alert(r); r = $(":radio:checked").eq(0).attr("id");
alert(r); r = $("#div1").children(":radio:checked").attr("id");
alert(r); r = $("#div1").children(":radio:checked").eq(0).attr("id");
alert(r); r = $("#div1").find(":radio:checked").eq(0).attr("id");
alert(r); $("#div1").find(":radio").each(function() {
alert($(this).attr("checked"));
if ($(this).attr("checked")) {
r = $(this).attr("id");
alert(r);
}
});
});
});
</script> <div id='div1'>
<input id="Radio1" name='rad' type="radio" />1<br/>
<input id="Radio2" name='rad' type="radio" />2
</div>
<input id="Button1" type="button" value="button" />

最新文章

  1. 关于localstorage的几个测试
  2. Oauth 2.0第三方账号登录原理图
  3. iOS-Gdata XML解析配置和简单使用
  4. 队列 - 从零开始实现by C++
  5. kafka中server.properties配置文件参数说明
  6. schedule和scheduleUpdate
  7. jQuery-ui treegird 使用
  8. 【6】了解Bootstrap栅格系统基础案例(1)
  9. Hot-Bar 軟板設計注意事項
  10. error C2018: unknown character &#39;0xa1&#39;
  11. [Python]sqlite3二进制文件存储问题(BLOB)(You must not use 8-bit bytestrings unless you use a text_factory...)
  12. 【BZOJ1834】 网络扩容
  13. 剑指Offer——搜狐畅游笔试题+知识点总结
  14. Salesforce的数据权限机制
  15. kernel中文件的读写操作可以使用vfs_read()和vfs_write
  16. hadoop hive install (5)
  17. Mongo命令批量更新某一数组字段的顺序
  18. linux centos 7 下安装ElasticSearch5.4
  19. WC2018伪题解
  20. web常见问题排查

热门文章

  1. 【转】MVC4验证用户登录特性实现方法
  2. Hibernate4.2.21.Final创建入门的HelloHibernet工程
  3. Linux 内核源码情景分析 chap 2 存储管理 (四)
  4. 【Linux】用户权限设置,配合FTP访问
  5. Ubuntu14.04安装redis-server
  6. npm stripts 使用指南
  7. [转]Oracle 10g如何对用户姓名,按首字母排序、查询
  8. js与php中一些相似函数的对比
  9. 源码编译安装git
  10. linux Find命令教程