radio被选中,但是重复点击后事件不触发

Posted on 2016-06-03 12:52  黄银  阅读(546)  评论(0编辑  收藏  举报

知识点:使用 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);   
    }
});