Why am I able to use jQuery syntax in Chrome's JS console when current page doesn't have jQuery loaded?

后端 未结 2 348
难免孤独
难免孤独 2021-01-20 00:33

I thought one has to have jQuery source loaded first in order to use $ to target elements. I was on a webpage that doesn\'t even include any scripts but somehow

相关标签:
2条回答
  • 2021-01-20 00:54

    As already alluded to in the comments by @Shmiddty, it is likely due to a plugin you have installed...

    You can find out by running developer tools, select 'Sources' and look at both the Sources and Content Scripts panes - is something suspiciously like jQuery in there somewhere?

    0 讨论(0)
  • 2021-01-20 01:14

    Before, Chrome had an alias to document.getElementById with the $ variable.

    Recently (probably on Chrome 23 release), it has been changed to an alias to document.querySelector.

    So your code is the equivalent of document.querySelector('body').

    0 讨论(0)
提交回复
热议问题