I saw some code around the web that uses the following statement
if ($($(this)).hasClass(\"footer_default\")) {
$(\'#abc\')
.appendTo($(this))
There is no specific need for double-wrapping and $($(this))
is exactly the same as $(this)
.
That said, I once found this double-wrapping in one file in my project, committed by another developer. Tracking the changes through revision, turned out that it started as $($(this).find('selector').first())
- that is, the result of some selector was wrapped to create a new object. Then for whatever reasons, the selector was removed and only the double-wrapping of this
remained. Needless to say, on the next commit it was changed to $(this)
.