简体   繁体   English

jQuery的点击第二次不起作用

[英]jquery click not working second time

 var a = 1;
 var b = 1;

 <script type="text/javascript">

     $(document).ready(function () {

         $('[id$=HyperLink3]').click(function () {

             if (a <= 4) {
                 alert("I am an alert box!")
                  a = a + 1
             }
         });
     });
</script>

<script type="text/javascript">

    $(document).ready(function () {

            $('[id$=HyperLink2]').click(function () {

                if (a >= 2) {
                    alert("I am an alert box!")
                      a = a - 1
                }
            });
    });
</script>

                    <asp:HyperLink ID="HyperLink3" runat="server" 

When i first click the arrows they work fine , but if i click other buttons in my page , the jquery stops working.It does not load the javascript again. 当我第一次单击箭头时,它们可以正常工作,但是如果我单击页面中的其他按钮,则jquery停止工作。它不会再次加载javascript。

Try this, works for me 试试这个,对我有用

$('selector').live('click', function () {

         //your code
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM