variable-caching

Does jQuery $(this) need to be cached

怎甘沉沦 提交于 2019-12-01 04:50:18
问题 I recently came accross some blog posts about jQuery performance (i.e. http://net.tutsplus.com/tutorials/javascript-ajax/10-ways-to-instantly-increase-your-jquery-performance/) and it was stated in all of them that we should cache the jQuery objects to javascript variables. What I need to know, though, is if this applies to $(this) as well. Am I going to gain in performance if I do this: $("#some-link").click("click", function(){ var $this = $(this); $this.doSomeThing(); }); Thank you in