Heim >Backend-Entwicklung >PHP-Tutorial >javascript - 点击关闭按钮两次才能关闭事件,求大神帮忙解决
<code><script> $(document).ready(function(){ $(".checkboxFour").addClass("click"); var evTimeStamp = 0; $(".click").click(function(event){ if($(this).find("input").is(":checked")==true){ $(this).find("input").attr("disabled",true); return ; } var now = +new Date(); if (now - evTimeStamp < 100) { return; } evTimeStamp = now; var obj = "<span class=\'clospan\' style=\'display:inline-block;padding:3px 5px;margin-right:5px;margin-bottom:5px;border-radius:5px;background-color:#E1E1E1;\'><span style=\'margin-right:4px;\';>" +$(this).text()+ "<a class=\'close\' href=\'javascript:void(0)\' style=\'text-decoration:none;display:inline-block;border-left:1px solid #FFF;padding:0 5px;color:#A1A0A0;\'>X"; $("#case_s_choice").append(obj); event.stopPropagation(); }); $(".tchkb-0").click(function(e){ e.stopPropagation(); }); $(document).on("click",".close",function(){ $(this).parents("span").remove(); var text = $(this).siblings("span").text(); $(".checkboxFour").each(function(){ if($(this).text() == text){ $(this).find("input").attr("disabled",false); $(this).find("input").click(); } }); }); }); </script>';</code>
<code><script> $(document).ready(function(){ $(".checkboxFour").addClass("click"); var evTimeStamp = 0; $(".click").click(function(event){ if($(this).find("input").is(":checked")==true){ $(this).find("input").attr("disabled",true); return ; } var now = +new Date(); if (now - evTimeStamp < 100) { return; } evTimeStamp = now; var obj = "<span class=\'clospan\' style=\'display:inline-block;padding:3px 5px;margin-right:5px;margin-bottom:5px;border-radius:5px;background-color:#E1E1E1;\'><span style=\'margin-right:4px;\';>" +$(this).text()+ "<a class=\'close\' href=\'javascript:void(0)\' style=\'text-decoration:none;display:inline-block;border-left:1px solid #FFF;padding:0 5px;color:#A1A0A0;\'>X"; $("#case_s_choice").append(obj); event.stopPropagation(); }); $(".tchkb-0").click(function(e){ e.stopPropagation(); }); $(document).on("click",".close",function(){ $(this).parents("span").remove(); var text = $(this).siblings("span").text(); $(".checkboxFour").each(function(){ if($(this).text() == text){ $(this).find("input").attr("disabled",false); $(this).find("input").click(); } }); }); }); </script>';</code>
我之前也遇到过,我的firefox,chrome上就要点两次,别人的就没事,也不是鼠标的原因