Skip to content Skip to sidebar Skip to footer

Jquery Double Object Constructor - E.g. $($(this))

Assume you have the following code: function name() { $(this).css('background', 'red'); } $('selector1').click(name); $('selector2').click(function () { name.call($(this)

Solution 1:

$(this) when this is already a jQuery object creates a copy of the jQuery object.

From the jQuery docs:

Cloning jQuery Objects

When a jQuery object is passed to the $() function, a clone of the object is created. This new jQuery object references the same DOM elements as the initial one.

Post a Comment for "Jquery Double Object Constructor - E.g. $($(this))"