欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery獲取Radio,CheckBox選擇的Value值(示例代碼)

 更新時(shí)間:2013年12月12日 10:16:42   作者:  
這篇文章主要是對(duì)jQuery獲取Radio,CheckBox選擇的Value值進(jìn)行了詳細(xì)的介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助

$("input[name='radio_name'][checked]").val(); //選擇被選中Radio的Value值
$("#text_id").focus(function(){//code...}); //事件 當(dāng)對(duì)象text_id獲取焦點(diǎn)時(shí)觸發(fā)
$("#text_id").blur(function(){//code...}); //事件 當(dāng)對(duì)象text_id失去焦點(diǎn)時(shí)觸發(fā)
$("#text_id").select(); //使文本框的Vlaue值成選中狀態(tài)
$("input[name='radio_name'][value='要選中Radio的Value值'").
attr("checked",true); //根據(jù)Value值設(shè)置Radio為選中狀態(tài)


jQuery獲取CheckBox選擇的Value值

$("input[name='checkbox_name'][checked]"); //選擇被選中CheckBox元素的集合 如果你想得到Value值你需要遍歷這個(gè)集合
$($("input[name='checkbox_name'][checked]")).
each(function(){arrChk+=this.value +',';});//遍歷被選中CheckBox元素的集合 得到Value值
$("#checkbox_id").attr("checked"); //獲取一個(gè)CheckBox的狀態(tài)(有沒有被選中,返回true/false)
$("#checkbox_id").attr("checked",true); //設(shè)置一個(gè)CheckBox的狀態(tài)為選中(checked=true)
$("#checkbox_id").attr("checked",false); //設(shè)置一個(gè)CheckBox的狀態(tài)為不選中(checked=false)
$("input[name='checkbox_name']").attr
("checked",$("#checkbox_id").attr("checked"));//根據(jù)3,4,5條,你可以分析分析這句代碼的意思
$("#text_id").val().split(","); //將Text的Value值以','分隔 返回一個(gè)數(shù)組

相關(guān)文章

最新評(píng)論