jQuery是否禁用/启用了JavaScript? [英] jQuery if javascript is disabled/enabled?

查看:85
本文介绍了jQuery是否禁用/启用了JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

观看此视频教程,我注意到他说他已经添加了这个:

$('html').addClass('js');

他说,如果禁用了javascript,则不会显示该类,但是如果启用了它,则将显示该类.我不明白那是怎么回事. jQuery如何知道是否启用了JS,以及如何在启用/禁用JS时应用某个类?没有if语句.我有点困惑.

如果HTML具有JS类,则可以使用javascript,否则不能使用JS".我不明白

他还提到了一个"JavaScript钩子".

从2:30到3:40观看,这是他解释的地方,但我听不懂.

谢谢!

我不敢相信答案是如此简单,而且我没有看到它.谢谢大家.

解决方案

jQuery JavaScript.这是一个用JavaScript编写的有用代码库.如果禁用了JavaScript,则jQuery也被禁用,因此您不会看到"js"类出现.这不是您在工作现场进行的测试.它更多是出于学习目的的演示.

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.

这篇关于jQuery是否禁用/启用了JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆