javascript - Using jQuery object understanding -


this question has answer here:

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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -