Is a click event associated with a button that is already associated with a click event causing problems?

Has the click event been associated with a button that has already caused click-related problems, caused problems?

+4
source share
4 answers

No. There will now be two click events on this button. Both will occur so that they are connected.

Try this simple example: http://jsfiddle.net/FQvJq/

$('#test') .click(function(){ alert('click callback 1')}) .click(function(){ alert('click callback 2')}) 
+2
source

No, events are accumulating .

+4
source

Technically, no, but it depends more on what your events are doing. They will be executed sequentially. Go think more about how these two events can affect each other.

In addition, it may be worthwhile to associate certain methods with events, as this will make it easier to disable - even if it does not apply to you an even better design, in my opinion.

0
source

Compared to jQuery 1.4.2, repeating event handlers can be bound to an element rather than to garbage. For instance:

 function test(){ alert("Hello"); } $("button").click( test ); $("button").click( test ); 

When a button is pressed, two warnings are called up.

In jQuery 1.4.3, you can now pass "false" instead of an event handler. This will bind an event handler equivalent to: function(){ return false; } function(){ return false; } . This function can be removed later by calling: .unbind( eventName, false ) .

I think this can help you. thanks

0
source

Source: https://habr.com/ru/post/1336487/


All Articles