如何向< html>添加类元素没有jQuery? [英] How do I add a class to the <html> element without jQuery?
本文介绍了如何向< html>添加类元素没有jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用jQuery(或类似的库)将类名foo添加到根< html>
元素 ?
How do I add the class name "foo" to the root <html>
element without using jQuery (or a similar library)?
推荐答案
只需获取元素并追加到类列表中即可。
Just get the element and append to the list of classes.
document.documentElement.className += " foo";
这篇关于如何向< html>添加类元素没有jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文