Javascript 如何重新加载css样式表

Javascript 如何重新加载css样式表,javascript,html,css,Javascript,Html,Css,也许我的问题的答案很简单,但我还没有找到答案。 我想知道是否可以在mouseover(mouseout)函数中调用“className”.css文件。例如: <div id="thing" class="classes" onmouseover="????call the .css file???">My Name</div> /// 我以为一旦鼠标退出,单词“我的名字”将再次变红(这是因为css文件),但事实并非如此。可以这样写吗 我的名字 我不想写这个: <d

也许我的问题的答案很简单,但我还没有找到答案。 我想知道是否可以在mouseover(mouseout)函数中调用“className”.css文件。例如:

<div id="thing" class="classes" onmouseover="????call the .css file???">My Name</div>
///

我以为一旦鼠标退出,单词“我的名字”将再次变红(这是因为css文件),但事实并非如此。可以这样写吗

我的名字 我不想写这个:

<div id="thing" class="classes" onmouseover="this.style.color='blue'" onmouseout = "this.style.color='red'">My Name</div>
我的名字
希望它清晰易懂。任何帮助都将不胜感激

谢谢
Joel

在CSS中使用
:hover
伪类

.classes:hover {
    color: blue;
}

您所需要的只是css中的css属性

div#thing{
    color: red;
}
div#thing:hover{
    color: blue;
}

是的,可以使用
:hover
伪选择器:

#thing { color: red; }
#thing:hover { color: blue; }

只需使用:hover伪选择器即可。
#thing { color: red; }
#thing:hover { color: blue; }