------------------------------------------------------------------------------ var style1 = document.createElement('style');
style1.innerHTML = '.check_button_getsport:hover {background-color: #79e08f;color: #ffffff; }';
document.head.appendChild(style1);
——————————————————————————————————————————————
以上为自己测试过的代码可以用,以下为在网上找的代码
<html>
<head>
<script>
function blue(){
if(document.all){
window.style="body{background-color:blue;";
document.createStyleSheet("javascript:style");
}else{
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML="body{ background-color:blue }";
document.getElementsByTagName('HEAD').item(0).appendChild(style);
}
}
</script>
</head>
<body>
<input type="button" value="blue" οnclick="blue();"/>
</body>
</html>