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.
objfor a dom object, and not a jquery one? It's generally considered good practice to prefix jquery objects with a dollar to indicate that they are indeed jquery objectsvar $foo = $(".foo");That way, when someone comes along later to update the code, they can immediately tell that $foo is a jQuery object and not a variable or something else.