I had to jump into jQuery development without getting too much time into learning all the associated basics, so there is one thing that throws me off quite a bit.
I see two different ways our developers access jQuery objects:
Case 1:
var container = $("#containerId");
// Then use it as:
container.hide();
Case 2:
var container = $("#containerId");
// Then use it as:
$(container).hide();
From my thin up to date knowledge, by wrapping a container as in var obj = $(container)
, we get a jQuery object obj
that we can further work with.
But then why do I see intermittently developers wrapping it again when using as in $(obj).doSomething()
?
Edit: the question suggested as duplicate is asking about best practices and although similar, my question is purely on understanding of jQuery object wrapping.