Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does $($(this)) mean?

I saw some code around the web that uses the following statement

if ($($(this)).hasClass("footer_default")) {       $('#abc')         .appendTo($(this))         .toolbar({position: "fixed"});     } 

What is the use of $($(this)) and why is that necessary here?

like image 407
guest Avatar asked Feb 10 '14 07:02

guest


People also ask

What does this mean )) in texting?

means "Happy."

What does this symbol means :')?

:') means "Crying with Joy" or "Sad Smile." The :') emoticon usually indicates that the sender found something so funny it brought tears to their eyes (i.e., they were crying with joy. However, it may also be used to express a sad smile.

What does 🙃 mean from a girl?

🙃 Upside-Down Face emoji The upside-down face emoji, sometimes known as the upside-down smiley face, has several meanings depending on the context and personality of the user. It can indicate silliness, sarcasm, irony, passive aggression, or frustrated resignation.

What does 🗿 mean from a guy?

Who uses 🗿 Moai emoji? The moai emoji is seen frequently in social-media posts that revolve around Japanese and Korean pop music (like BTS, also known as Bangtan Boys), and in posts related to Japanese and Polynesian culture in general. However, it can also be used to imply strength, silence, and mystery.


2 Answers

Yes, $($(this)) is the same as $(this), the jQuery() or $() function is wonderfully idempotent. There is no reason for that particular construction (double wrapping of this), however, something I use as a shortcut for grabbing the first element only from a group, which involves similar double wrapping, is

$($('selector')[0])

Which amounts to, grab every element that matches selector, (which returns a jQuery object), then use [0] to grab the first one on the list (which returns a DOM object), then wrap it in $() again to turn it back into a jQuery object, which this time only contains a single element instead of a collection. It is roughly equivalent to

document.querySelectorAll('selector')[0];, which is pretty much document.querySelector('selector');

like image 135
chiliNUT Avatar answered Oct 11 '22 23:10

chiliNUT


You can wrap $ as many times as you want, it won't change anything.

If foo is a DOM element, $(foo) will return the corresponding jQuery object.

If foo is a jQuery object, $(foo) will return the same object.

That's why $($(this)) will return exactly the same as $(this).

like image 44
sdabet Avatar answered Oct 11 '22 23:10

sdabet