javascript - Using jQuery object understanding -
this question has answer here:
- jquery selector re-use best practice 2 answers
i had jump jquery development without getting time learning associated basics, there 1 thing throws me off quite bit.
i see 2 different ways our developers access jquery objects:
case 1:
var container = $("#containerid"); // use as: container.hide();
case 2:
var container = $("#containerid"); // use as: $(container).hide();
from thin date knowledge, wrapping container in var obj = $(container)
, jquery object obj
can further work with.
but why see intermittently developers wrapping again when using in $(obj).dosomething()
?
edit: question suggested duplicate asking best practices , although similar, question purely on understanding of jquery object wrapping.
second wrapping nothing remember. if there can selector dom element or juery object can wrap , not care was.
but if know jquery object, shouldn't use wrapping.
Comments
Post a Comment