javascript - 点击关闭按钮两次才能关闭事件,求大神帮忙解决

WBOY
Release: 2016-06-06 20:22:08
Original
1333 people have browsed it

<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>
Copy after login
Copy after login

回复内容:

<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>
Copy after login
Copy after login

我之前也遇到过,我的firefox,chrome上就要点两次,别人的就没事,也不是鼠标的原因

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!