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?
means "Happy."
:') 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.
🙃 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.
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.
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');
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With