JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

16.6.1 Enabling and Disabling Stylesheets

16.6.1 Enabling and Disabling Stylesheets


The simplest stylesheet scripting technique is also the most portable and robust.elements,elements, and CSSStyleSheet objects all define a disabled property that you can query and set in JavaScript. As its name implies, if the disabled property is true, then the stylesheet is disabled and is ignored by the browser.

The disableStylesheet() function below demonstrates this. If passed a number, it treats it as an index into the document.styleSheets array. If passed a string, it treats it as a CSS selector and passes it to document.querySelectorAll() (see §15.2.5 ), then sets the disabled property of all returned elements:

function disableStylesheet(ss) {

if (typeof ss === "number")

document.styleSheets[ss].disabled = true;

else {

var sheets = document.querySelectorAll(ss);

for(var i = 0; i < sheets.length; i++)

sheets[i].disabled = true; }

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/31450.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1