首页 > 技术文章 > radio被选中,但是重复点击后事件不触发

huangyin1213 2016-06-03 12:52 原文

知识点:使用 jq的prop才能设置

html

复制代码
$('.ss').click(function(){
               $(this).find("input[type=radio]").attr("checked",true);
   });

<ul>
  <li class="ss"><input type="radio" name="radio" class="fc" id="radio" value="a" />fdfd</li>
  <li class="ss"><input type="radio" name="radio" class="fc" id="radio" value="b" />qqqq</li>
  <li class="ss"><input type="radio" name="radio" class="fc" id="radio" value="c" />wwww</li>
  </ul>
复制代码

js

复制代码
$('.ss').click(function(){
    var    $radio = $(this).find("input[type=radio]"),
           $flag  = $radio.is(":checked");
    if( !$flag ){
        $radio.prop("checked",true);   
    }
});

推荐阅读