我有一个像这样的 Accordion 标题,
<div id="accordion">
<h3 id="header1"><a href="#">Stuff: <span id="text">Text </span></a></h3>
在某些事件发生时,我更改了 <span id="text">
的颜色.
$("h3 #text).css("color","red");
我想要做的是将颜色改回默认的 Accordion 标题颜色。我可以将它改回默认颜色,但是当您将鼠标悬停在它上面或单击它时,它不会改变颜色。
有没有办法改变它的类之类的?
最佳答案
是的,toggleClass .你想要这样的东西:
$("h3 #text).mouseEnter(function{$("h3 #text).toggleClass("header1Active");});
$("h3 #text).mouseLeave(function{$("h3 #text).toggleClass("header1Active");});
你有一些CSS:
h3.header1Active {
color: red
}
关于css - jQueryUI Accordion 标题 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7452101/