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

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

tags - Jquery Mixitup plugin help prevent handlers being destroyed -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -