日期:2014-05-16  浏览次数:20446 次

不知为何这个JQ事件总是执行两次,如何修正?
本帖最后由 kinghome 于 2013-06-06 19:27:07 编辑
不知为何这个JQ事件总是执行两次,如何修正?

$("fieldset[data-FormUi=radio]").on("click",function(e){
var target = $(e.currentTarget),
tagName = target.attr("name"),
stuta = target.attr("data-activity");
/*判断当前状态*/
if(stuta == undefined)
stuta = false;
else
stuta =  Boolean(stuta);

/*修改当前状态*/
var setStateVal = stuta ? "false":"true";
target.attr("data-activity",setStateVal);

e.stopPropagation();
})


<div class="grid-a">
                      <div class="cell">
                          <fieldset data-FormUi="radio"  name="sexgroup">
                             <label>
                                 Man <input type="radio" value="man" name="sex" style="display:none"/>
                                </label>
                            </fieldset> 
                         </div>
                        <div class="cell"> 
                          <fieldset data-FormUi="radio" name="sexgroup">
                             <label>
                                 Woman <input type="radio" value="woman" name="sex"  style="display:none"/>
                                </label>
                            </fieldset> 
                        </div>
                     </div>