简体   繁体   中英

click event fires twice

I wanted some nice buttons so I use .button() in jQuery like this:

$(document).ready(function() {
    $("#idBlaBla").button();
});

server side:

 Private Sub btnSaveVisible_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveVisible.ServerClick 

The problem is that when I click it fires the even twice. It doesn't happen in debug with visual studio 2008. but when the website is online, every buttons with jQuery trigger the event twice.

Any ideas?

Thank you

In that case, we can do the following

$('selected').unbind('click').bind('click', function (e) {
  add_course(this);
});

I had the event firing two times initially, when the page get refreshed it fires four times. It was after many fruitless hours before I figured out with a google search.

I must also say that the code initially was working until I started using the JQueryUI accordion widget.

try this:

//call event click or press button
$('#idBlaBla').click();

//listen event
$('#idBlaBla').click(function( event ){
    //your code here...
});

//listen multi events
$('#idBlaBla').bind('click focus blur',function( event ){
    //your code here...
});

//listen new element(append fro example)
$('.div').append( '<a href="" id="idBlaBla">Anchor Button</a>' );
$('#idBlaBla').live('click',function( event ){
    //your code here...
});

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