js中怎么改变外部css中的属性值
2个回答
展开全部
<style>.win{display:none}</style>
<div id="w" class="win">
这是DIV登录框示例<br>
</div>
<script>
function changecss(theClass, element, value) {
var cssRules;
if (document.all) {
cssRules = 'rules';
}
else if (document.getElementById) {
cssRules = 'cssRules';
}
for (var S = 0; S < document.styleSheets.length; S++) {
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
document.styleSheets[S][cssRules][R].style[element] = value;
}
}
}
}
window.onload = function () {
changecss('.win', 'display', 'block');
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询