<script type="text/javascript">
$(function () {
一、radio
1.获取选中值,三种方法都可以: $('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val(); 2.设置第一个radio为选中值:
$('input:radio:first').attr('checked', 'checked');
或者
$('input:radio:first').attr('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true); 3.设置最后一个radio为选中值:
$('input:radio:last').attr('checked', 'checked');
或者
$('input:radio:last').attr('checked', 'true'); 4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....
或者
$('input:radio').slice(1,2).attr('checked', 'true'); 5.根据value值设置radio为选中值
$("input:radio[value=gzmsg.com]").attr('checked','true');
或者
$("input[value=gzmsg.com").attr('checked','true'); 6.删除value值为gzmsg.com的radio
$("input:radio[value=gzmsg.com]").remove(); 7.删除第几个radio
$("input:radio").eq(索引值).remove();索引值=0,1,2....
如删除第3个radio,$("input:radio").eq(2).remove(); 8.遍历Radio
$('input:radio').each(function(index,domEle){
//写入代码
}); 二、select
1.获取选中项:
获取选中项的Value值:
$('select#sel option:selected').val();
或者
$('select#sel').find('option:selected').val();
获取选中项的Text值:
$('select#seloption:selected').text();
或者
$('select#sel').find('option:selected').text(); 2.获取当前选中项的索引值:
$('select#sel').get(0).selectedIndex; 3.获取当前option的最大索引值:
$('select#sel option:last').attr("index"); 4.获取DropdownList的长度:
$('select#sel')[0].options.length;
或者
$('select#sel').get(0).options.length; 5.设置第一个option为选中值:
$('select#sel option:first').attr('selected','true')
或者
$('select#sel')[0].selectedIndex = 0; 6.设置最后一个option为选中值: 三、checkbox
1、$(".chk").click(function(){}); 2、设置选中项
$("input[name='box']").attr("checked","checked"); 3.获取被选中的checkbox的值:
$("input[name='box'][checked]").each(function(){
if (true == $(this).attr("checked")) {
alert( $(this).attr('value') );
}
或者:
$("input[name='box']:checked").each(function(){
if (true == $(this).attr("checked")) {
alert( $(this).attr('value') );
} 4.获取未选中的checkbox的值:
$("input[name='box']").each(function(){
if ($(this).attr('checked') ==false) {
alert($(this).val());
}
}); 5.设置checkbox的value属性的值:
$(this).attr("value",值);
})
</script>

jQuery 操作 radio、select、checkbox的更多相关文章

  1. [转]jQuery操作radio、checkbox、select 集合.

    1.radio:单选框 html代码 <input type="radio" name="radio" id="radio1" val ...

  2. jQuery操作radio、checkbox、select 集合

    1.radio:单选框 HTML代码: <input type="radio" name="radio" id="radio1" va ...

  3. jQuery操作radio、checkbox、select总结

    1.radio:单选框 HTML代码: <input type="radio" name="radio" id="radio1" va ...

  4. jquery实用应用之jquery操作radio、checkbox、select

    本文收集一些jquery的实用技巧,非常实用的哦,其中对radio.checkbox.select选中与取值的方法. 获取一组radio被选中项的值var item = $('input[@name= ...

  5. jQuery 操作input select,checkbox

    input $("#add_device_owner_id").val() $("#add_device_owner_id").val("d" ...

  6. jquery的radio和checkbox的标签的操作集合

    jquery的radio和checkbox的标签的操作集合: $("input[name='radio_name'][checked]").val(); //选择被选中Radio的 ...

  7. JS中Float类型加减乘除 修复 JQ 操作 radio、checkbox 、select LINQ to SQL:Where、Select/Distinct LINQ to SQL Count/Sum/Min/Max/Avg Join

    JS中Float类型加减乘除 修复   MXS&Vincene  ─╄OvЁ  &0000027─╄OvЁ  MXS&Vincene MXS&Vincene  ─╄Ov ...

  8. jQuery 操作 input 之 checkbox

    jQuery 操作 input 之 checkbox 一片 HTML 清单: <input type="checkbox" name="hobby" va ...

  9. 使用JQUERY操作Radio

    发展中经常使用Radio为了实现用户的选择的影响.我在该项目中使用的一些JQUERY操作Radio该方法.这里分享,对于有需要的朋友参考的. 1.变化radio选择.引发一些结果 $("in ...

  10. jquery选中radio或checkbox的正确姿势

    jquery选中radio或checkbox的正确姿势 Intro 前几天突然遇到一个问题,没有任何征兆的..,jquery 选中radio button单选框时,一直没有办法选中,后来查了许多资料, ...

随机推荐

  1. [Unity3D]Unity3D游戏开发之角色控制漫谈

    各位朋友,大家好.我是秦元培,欢迎大家关注我的博客,我的博客地址blog.csdn.net/qinyuanpei.今天呢,我们来说说Unity3D中的角色控制,这篇文章并非关注于Unity3D中的某项 ...

  2. delphiredisclient开源GIT

    delphiredisclient - Redis client for Delphi Delphi Redis Client版本2(此分支)与Delphi 10.1 Berlin兼容,更好.警告!如 ...

  3. iPhone系统常用文件夹位置

    1. [/Applications]   常用软件的安装目录 2.    [/private /var/ mobile/Media /iphone video Recorder]   iphone v ...

  4. 图标框架Font Awesome

    直接引入Font Awesome的css <!DOCTYPE html> <html lang="en"> <head> <meta ch ...

  5. 技术人生:special considerations that are very important

    For the most part, a lot of what we know about software development can be applied to different envi ...

  6. Tomcat中session的管理机制

    1.       请求过程中的session操作: 简述:在请求过程中首先要解析请求中的sessionId信息,然后将sessionId存储到request的参数列表中.然后再从 request获取s ...

  7. spring源代码分析

    预初始化beanDefaultListableBeanFactory preInstantiateSingletons

  8. versionCode溢出的问题

    android应用的版本主要由versionCode和versionName来决定,android系统是根据versionCode来验证新的apk是否能安装.如果已安装高版本的应用,就无法使用覆盖安装 ...

  9. MyEclipse的破解和汉化方法

    一.安装和破解 我的MyEclipse是从官网下的正版软件,在其他地方下载的版本同理. 官方下载地址(需FQ): http://www.myeclipseide.com/module-htmlpage ...

  10. java 模拟发送post请求测试

    方法一: HttpClient public void postTest(HttpServletRequest request,Integer type,String phone,String pas ...