获取一组radio被选中项的值:var item = $('input[name=items][checked]').val();
获取select被选中项的文本:var item = $("select[@name=items] option[@selected]").text();

获取select被选中项的文本 :var item = $("select[name=items] option[selected]").text(); 或$("select[name=items]").find("option:selected").text();

select下拉框的第二个元素为当前选中值:$('#select_id')[0].selectedIndex = 1;

select下拉框value = 'val'的元素为当前选中项:$("select[name=items] option[value='val']").attr("selected","selected");

radio单选组的第二个元素为当前选中项 :$('input[@name=items]').get(1).checked = true; 或$('input[name=items]').attr("checked", '1′);

radio的value = 'val'的元素为当前选中项:$('input[name=items] [value='val']').attr("checked","checked");

获取值:

文本框,文本区域:$("#txt").attr("value");

多选框checkbox:$("input[name='checkbox':checked]").each(function(){

var val = $(this).val();

});

单选组radio: $("input[type=radio][checked]").val();

下拉框select的value值: $('select').val();

下拉框select选中的text 值:$("select").find("option:selected").text();

控制表单元素:

文本框,文本区域:$("#txt").attr("value","); //清空内容

$("#txt").attr("value",'11′); //填充内容

多选框checkbox:
checkbox的第二个元素被打勾:$("input[name=items]").get(1).checked = true; //打勾
                                           $("input[name=items]").get(1).checked = false; //不打勾

checkbox的value='val'的元素前打勾:$("input[name=item][value='val']").attr("checked",true); 或$("input[name=item][value='val']").attr("checked","checked");

if($("input[name=item][value='val']").attr('checked')==true) //判断是否已经打勾

单选组radio: $("input[type=radio]").attr("checked",'2′);//设置value=2的项目为当前选中项

下拉框select: $("#sel").attr("value",'-sel3′);//设置value=-sel3的项目为当前选中项

$("

2222").appendTo("#sel")//添加下拉框的option

$("#sel").empty();//清空下拉框

jQuery获取Radio选择的Value值

代码

$("input[name='radio_name'][checked]").val(); //选择被选中Radio的Value值
$("#text_id").focus(function(){//code...}); //事件 当对象text_id获取焦点时触发
$("#text_id").blur(function(){//code...}); //事件 当对象text_id失去焦点时触发
$("#text_id").select(); //使文本框的Vlaue值成选中状态
$("input[name='radio_name'][value='要选中Radio的Value值'").
attr("checked",true); //根据Value值设置Radio为选中状态

jQuery获取CheckBox选择的Value值

$("input[name='checkbox_name'][checked]"); //选择被选中CheckBox元素的集合 如果你想得到Value值你需要遍历这个集合
$($("input[name='checkbox_name'][checked]")).
each(function(){arrChk+=this.value + ',';});//遍历被选中CheckBox元素的集合 得到Value值
$("#checkbox_id").attr("checked"); //获取一个CheckBox的状态(有没有被选中,返回true/false)
$("#checkbox_id").attr("checked",true); //设置一个CheckBox的状态为选中(checked=true)
$("#checkbox_id").attr("checked",false); //设置一个CheckBox的状态为不选中(checked=false)
$("input[name='checkbox_name']").attr
("checked",$("#checkbox_id").attr("checked"));//根据3,4,5条,你可以分析分析这句代码的意思
$("#text_id").val().split(","); //将Text的Value值以','分隔 返回一个数组

jquery1.3.2

ISDARK : $("input[@type=radio][name=ISDARK][checked]").val()

$("input[name=radioname][value=radio值]").attr("checked","checked");

【转】jQuery获取Select option 选择的Text和Value的更多相关文章

  1. jquery 获取Select option 选择的Text和Value

    jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关设置 获取一组radio被选中项的值:var item = $(' ...

  2. jQuery获取Select option 选择的Text和 Value

    获取一组radio被选中项的值:var item = $('input[name=items][checked]').val();获取select被选中项的文本var item = $("s ...

  3. jQuery获取select option

    jQuery的一些方法理出一些常用的方法: //获取第一个option的值 $('#test option:first').val(); //最后一个option的值 $('#test option: ...

  4. Jquery获取select option动态添加自定义属性值失效

    Jquery获取select option动态添加自定义属性值失效 2014/12/31 11:49:19 中国学网转载 编辑:李强 http://www.xue163.com/588880/3909 ...

  5. 用Jquery获取select的value和text值

    $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发 var checkText=$(&q ...

  6. 通过JQUERY获取SELECT OPTION中选中的值

    遇到一样学一样. 一个是取KEY,一个是取VALUE,一个是取所有文本. var dbuser_select = $("#dbuser_select option:selected" ...

  7. jquery获得select option的值和对select option的操作

    <body> <select name="month" id="selMonth" onchange="set()"> ...

  8. jQuery获取Select选择的Text和 Value(转)用时比较方便寻找

    ---恢复内容开始--- jQuery获取Select选择的Text和Value:语法解释:1. $("#select_id").change(function(){//code. ...

  9. jQuery获取Select选择的Text和 Value(转)

    radio: radio: var item = $('input[name=items][checked]').val(); var item = $('input[name=items]:chec ...

随机推荐

  1. STM32 串口固件库中定义的几个中断标志位什么意思?

    在stm32f10x_usart.h中以上几个宏,很没有规律,诈一看还真不知道为什么会这么定义,其实通过代码就很容易明白: D7~D5:代表中断标志位对应的中断使能位在 CR1.CR2还是CR3寄存器 ...

  2. DOM hash

    前段时间做的一个H5专题,用到了hash解决问题,特意记录一下.DOM hash的详细内容可以点击链接查看. hash就是uri中#及后面的部分,例如:www.google.com.hk#123的#1 ...

  3. MySQL使用技巧收集,持续更新中......

    1.查询时按某一内容为中文的字段,以拼音字母排序: SELECT * FROM game ORDER BY CONVERT(name USING GBK);

  4. C#WebForm内置对象

    内置对象: Response对象:响应请求Response.Write("<script>alert('添加成功!')</script>");Respons ...

  5. 验证控件jQuery Validation Engine简单自定义正则表达式

    首先上控件的地址http://code.ciaoca.com/jquery/validation-engine/ 具体使用方式网站里说的很清楚,我写这篇文章主要是用于记录如何自己添加自定义正则表达式, ...

  6. java selenium (三) 环境搭建 基于Maven

    现在Java的大部分项目都是基于Maven,  在Maven项目中使用Selenium2. 非常简单. 首先你需要配置好Maven的环境 可以参考本博客的Maven教程系列,Maven入门教程(一) ...

  7. iOS安全相关学习资料

    https://github.com/zhengmin1989/iOS_ICE_AND_FIRE  (冰与火代码) http://weibo.com/zhengmin1989?is_hot=1 (蒸米 ...

  8. text-justify实操

    转自:http://www.zhangxinxu.com/wordpress/?p=1514 CSS代码: .video-list{width:540px; margin-left:auto; mar ...

  9. C宏展开的几个注意事项

    前阵子仔细重新研究了一下C的宏展开.总结起来,有以下几个主要规则: 每次宏展开的结果会被重复扫描,直到没有任何可展开的宏为止. 每展开一个宏,都会记住这次展开,在这个宏展开的结果及其后续展开中,不再对 ...

  10. struts下ajax提交与页面进行提示 返回值为null

    @Override    public String execute() throws Exception {        if ("none".equals(task)) {  ...