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

javascript - CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any -

codeigniter - Fatal error: Call to undefined function lang() in CI Merchant using CardSave -

python - Received unregistered task using Celery with Django -