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 I was able to run $('body') inside the Javascript console and Chrome successfully returned its value.
Why didn’t I get a syntax error like ‘undefined token’? Thanks.
Before, Chrome had an alias to
document.getElementByIdwith 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').