<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, 首先看jQuery是否引用了,F12 刷新,如果发现控制台报错:“Uncaught ReferenceError: $ is not defined”,说明没有引用jQuery
2,换一种写法看看,看看但你点击input的时候,是否进去到这个方法,例如:
3,如果打印了print,换一种写法,如下试试看: