Can I use JQuery functions on a variable and not have JQuery reference the DOM over and over again? -
var x = $("element"); $(x).width(95);
very, new jquery. want item dom , use jquery functions on item. want make sure not getting item dom on , on again. or getting item dom second time?
if can avoid , use jquery functions? how that?
do need care? feel should.
i want make sure not getting item dom on , on again. or getting item dom second time?
no.
$()
returns jquery object contains collection of elements. have been found in dom.
you not need pass $
either, "$
":
var x = $("element"); x.width(95);
if pass $
object $
, creates copy of collection - not search items again, clones list.
do need care? feel should.
yes, , should. executing selector against dom can expensive. don't want executing every time.
Comments
Post a Comment