I was watching this video tutorial and I noticed he said that he’s added this:
$('html').addClass('js');
He said that if javascript is disabled, then the class won’t show, but if it is enabled, the class will show. I don’t understand how that works. How does jQuery know if JS is enabled, and to apply a certain class when JS is enabled/disabled? There’s no if statement. I’m a tad bit confused.
“If HTML has a class of JS, javascript is available, if not, JS is not available”. I don’t understand that.
He also mentioned a “JavaScript hook”..?
Watch from 2:30 to 3:40, it’s where he explains it but I don’t understand.
Thanks!
edit: I cannot believe the answer was so simple and I did not see it. Thanks guys.
jQuery is JavaScript. It’s a library of useful code, written in JavaScript. If JavaScript is disabled, so is jQuery, so you won’t see the “js” class appear. It’s not the sort of test you’d do on a working site; it’s more of a demonstration for learning purposes.