简体   繁体   中英

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.

Try this, works for me

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

         //your code
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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