为了账号安全,请及时绑定邮箱和手机立即绑定

点击输入框,怎么让一个单选框变为选中状态,jQuery怎么写 谢谢大家

点击输入框,怎么让一个单选框变为选中状态,jQuery怎么写 谢谢大家

慕婉清6462132 2019-02-14 14:15:27
<label >    <input  class="iii" type="radio" id="" name="nihao" >    <input name="x_y"  type="text" class="rrr"></label><script>$(".rrr").focus(function(){    $(this).siblings("input[type='radio']").prop("checked", true)// $(this).siblings(这里写入checkbox的class).attr(checked, true)});</script>这个代码不可以,有人知道为什么吗,哪里写错了吗,万分感激
查看完整描述

1 回答

?
大话西游666

TA贡献1817条经验 获得超14个赞

这个问题的解决思考有以下几种:

1, 首先看jQuery是否引用了,F12 刷新,如果发现控制台报错:“Uncaught ReferenceError: $ is not defined”,说明没有引用jQuery

2,换一种写法看看,看看但你点击input的时候,是否进去到这个方法,例如:


$(".rrr").click(function() {

   console.log('print');

});

3,如果打印了print,换一种写法,如下试试看:


  jQuery(".rrr").click(function() {

    jQuery('.iii').attr("checked", true);

});


查看完整回答
反对 回复 2019-02-25
  • 1 回答
  • 0 关注
  • 847 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号