AdmSteck
AdmSteck

Reputation: 1761

Add handler multiple times in jquery

How does jquery handle event assignment when it comes to assigning the same handler multiple times? Let's say I have

<div class="draggable">Some Text</div>

Are there any side effects (performance or otherwise) from calling the following multiple times?

$('.draggable').draggable();

Upvotes: 1

Views: 854

Answers (1)

jAndy
jAndy

Reputation: 236122

If you bind a event like 'keydown' multiple times to an element, it will get attached to a queue of event handlers. So you can do the math, the more handlers are called, the slower it will perform.

Upvotes: 5

Related Questions