Reputation: 145
What is the best utilization for multiple jquery selector ?
jQuery(this) / jQuery('#id')
or
var _this = jQuery(this)
?
Upvotes: 0
Views: 33
Reputation: 26258
The main diff between
jQuery('#id');
and
var selector = jQuery('#id');
for first type, if you are calling the same thing more than one time than for each call there is DOM traverse to get the element reference, but in second case it saves the reference and do not traverse DOM for each request. This saves the overhead.
Upvotes: 1