javascript - Caching jQuery variables -
i read if referring same dom element on , on in function better cache them in local variable :
var btn = $('#clearbtn');
i have followed necessary when accessing object have used $(btn).somemethod();
although can access directly btn.somemethod();
i need know whether have negative impact ?
there's no point in passing jquery object through jquery constructor. it's wasteful. if dollar sign looks nice you, prepend variable name , use $btn
in place of $(btn)
:
var $btn = $('#clearbtn');
Comments
Post a Comment