最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery

来源:懂视网 责编:小采 时间:2020-11-27 21:17:07
文档

jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery

jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery:$(input[name='radio_name'][checked]).val(); //选择被选中Radio的Value值$(#text_id).focus(function(){//code...}); //事件 当对象text_id获取焦点时触发$(#text_id).blur(function(){//code...});
推荐度:
导读jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery:$(input[name='radio_name'][checked]).val(); //选择被选中Radio的Value值$(#text_id).focus(function(){//code...}); //事件 当对象text_id获取焦点时触发$(#text_id).blur(function(){//code...});

$("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值以','分隔 返回一个数组

文档

jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery

jQuery获取Radio,CheckBox选择的Value值(示例代码)_jquery:$(input[name='radio_name'][checked]).val(); //选择被选中Radio的Value值$(#text_id).focus(function(){//code...}); //事件 当对象text_id获取焦点时触发$(#text_id).blur(function(){//code...});
推荐度:
标签: 选中的 check jQuery
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top