首页 > Web开发 > 详细

js操作styleSheets

时间:2016-04-25 06:34:55      阅读:282      评论:0      收藏:0      [点我收藏+]
Base.prototype.addRule = function (num, selectorText, cssText, position) {
	var sheet = document.styleSheets[num];
	if (typeof sheet.insertRule != ‘undefined‘) {
	       sheet.insertRule(selectorText + "{" + cssText + "}", position);
	} else if (typeof sheet.addRule != ‘undefined‘) {
	       sheet.addRule(selectorText, cssText, position);
	}
};
//移除link 或style 中的CSS 规则
Base.prototype.removeRule = function (num, index) {
	var sheet = document.styleSheets[num];
	if (typeof sheet.deleteRule != ‘undefined‘) {
	       sheet.deleteRule(index);
	} else if (typeof sheet.removeRule) {
	       sheet.removeRule(index);
	}
	return this;
};

 

js操作styleSheets

原文:http://www.cnblogs.com/fangxuele/p/5429101.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!