javascript - JQuery - Events binding and cached elements -
having code one
$a = $('#a'); $b = $('#b'); $c = $('#c'); $('#a, #b, #c').keyup(function () { //event handling });
i know
- if possible use existing cached elements handle events instead of selector.
- if possible , proper, make difference?
of course, using cached elements better performance. if want bind function on multiple cached elements, can use .add()
:
$a.add($b).add($c).keyup(function(){});
Comments
Post a Comment