首页 > PHP > jquery radio取值,checkbox取值,select取值,radio选中

jquery radio取值,checkbox取值,select取值,radio选中

2009年09月04号
查看评论 发表评论 806次浏览

jquery radio取值,checkbox取值,select取值,radio选中,

var item = $(’input[@name=items][@checked]‘).val();
获取select被选中项的文本

var item = $(”select[@name=items] option[@selected]“).text();
select下拉框的第二个元素为当前选中值

$(’#select_id’)[0].selectedIndex = 1;
radio单选组的第二个元素为当前选中值

$(’input[@name=items]‘).get(1).checked = true;
获取值:

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

多选框checkbox:$(”#checkbox_id”).attr(”value”);

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

下拉框select: $(’#sel’).val();

控制表单元素:

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

$(”#txt”).attr(”value”,’11′);//填充内容
多选框checkbox: $(”#chk1″).attr(”checked”,”);//不打勾

$(”#chk2″).attr(”checked”,true);//打勾

if($(”#chk1″).attr(’checked’)==undefined) //判断是否已经打勾
单选组radio: $(”input[@type=radio]“).attr(”checked”,’2′);//设置value=2的项目为当前选中项
下拉框select: $(”#sel”).attr(”value”,’-sel3′);//设置value=-sel3的项目为当前选中项

$(”<optionvalue=’1′>1111</option><optionvalue=’2′>2222</option>”).appendTo(”#sel”)//添加
下拉框的option

$(”#sel”).empty();//清空下拉框
获取一组radio被选中项的值

var item = $(’input[@name=items][@checked]‘).val();
获取select被选中项的文本

var item = $(”select[@name=items] option[@selected]“).text();
select下拉框的第二个元素为当前选中值

$(’#select_id’)[0].selectedIndex = 1;
radio单选组的第二个元素为当前选中值

$(’input[@name=items]‘).get(1).checked = true;
获取值:

文本框,文本区域:$(”#txt”).attr(”value”);
多选框checkbox:$(”#checkbox_id”).attr(”value”);
单选组radio: $(”input[@type=radio][@checked]“).val();
下拉框select: $(’#sel’).val();
控制表单元素:

文本框,文本区域:$(”#txt”).attr(”value”,”);//清空内容
$(”#txt”).attr(”value”,’11′);//填充内容
多选框checkbox: $(”#chk1″).attr(”checked”,”);//不打勾
$(”#chk2″).attr(”checked”,true);//打勾
if($(”#chk1″).attr(’checked’)==undefined) //判断是否已经打勾
单选组radio: $(”input[@type=radio]“).attr(”checked”,’2′);//设置value=2的项目为当前选中项
下拉框select: $(”#sel”).attr(”value”,’-sel3′);//设置value=-sel3的项目为当前选中项
$(”<option value=’1′>1111</option><option value=’2′>2222</option>”).appendTo(”#sel”)//添加下拉框的option
$(”#sel”).empty();//清空下拉框

类别PHP 标签
  1. sfsd
    发表于 2009年09月30号 10时35分33秒 | 1楼

    dgdfgdfgf

  2. timberland boots
    发表于 2010年06月13号 15时21分35秒 | 2楼

    Agree 100%. Just shows at the end of the day we are all people not a colour statistic.

  3. Herve Leger Skirts
    发表于 2010年06月14号 13时52分36秒 | 3楼

    haha, good luck with the next work, sure it’ll be groundbreaking.

  4. miu miu bags
    发表于 2010年06月23号 04时41分00秒 | 4楼

    by the way I forgot the most important… your story is great, I love it from the beginning to the very end.

  5. nike airforce one
    发表于 2010年06月25号 20时52分56秒 | 5楼

    You’re so right.

  6. lebron basketball shoes
    发表于 2010年06月28号 08时43分39秒 | 6楼

    thank you so much for sharing those moments with us…it made want to do the same path…

  7. ghd hair straighteners
    发表于 2010年07月20号 14时07分52秒 | 7楼

    ….yip, keep it simple…. hehehe….

  8. mbt shoes sale
    发表于 2010年07月26号 08时47分34秒 | 8楼

    I opened this blog post with the hope that that would specifically be addressed and I found your comments very insightful.