What does $($(this)) mean?

后端 未结 6 1419
借酒劲吻你
借酒劲吻你 2021-02-04 23:53

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

if ($($(this)).hasClass(\"footer_default\")) {
      $(\'#abc\')
        .appendTo($(this))
             


        
6条回答
  •  长情又很酷
    2021-02-05 00:12

    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).

提交回复
热议问题