日期:2014-05-16  浏览次数:20341 次

问个Js操作Css的难度问题?高人进
Css:
#id{font-size:14px;}
#id   a{color:red;}
#id   a:hover{color:blue;}

Javasctipt
id.style.fontSize= "18px ";
a.style.color= "yellow ";

问题
Js中如何对a:hover进行操作



------解决方案--------------------
<style>
#ice a{
color:red;
}
#ice a:hover{
color:blue;
}
</style>
</head>
<body>
<div id= "ice "> <a href= "# "> test </a> </div>
<input type= "button " value= "setCSS " onclick= "document.styleSheets[0].rules[1].style.color= '#ff0 ' "/>
</body>