鼠标移开时恢复为原始 CSS
我正在尝试使 AjaxControlToolkit Accordion 控件更改鼠标悬停和鼠标移出时的标题样式。它工作正常,但是当用户将鼠标悬停在当前选定的标题上然后将其保留时,所选标题的特殊 CSS 会被我分配的 mouseout 类覆盖。我只是在
中使用 onmouseover="this.className='AccHover'"
和 onmouseout="this.className='AccMouseOut'"
; 手风琴标题部分内的
标记。有没有办法删除 mouseout 事件上的 AccHover 类,并根据手风琴窗格状态自动恢复为未选定的 CSS 样式或选定的标题样式?
I'm trying to make an AjaxControlToolkit Accordion control change the header style on mouseover and mouseout. It works fine but when the user mouses over the currently selected header then leaves it the special CSS for selected headers is overwritten by the mouseout class that I've assigned. I'm just using onmouseover="this.className='AccHover'"
and onmouseout="this.className='AccMouseOut'"
in a <div>
tag inside the accordions header sections.
Is there a way to remove the AccHover class on the mouseout event and have it revert back to either the unselected CSS style or the Selected header style depending on the accordion panes state automatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会使用:
onmouseover="this.classList.add('AccHover')"
和
onmouseout="this.classList.remove('AccHover')"
编辑:好的我刚刚记得
classList
在 IE 中不起作用,我假设这就是您正在测试的内容。在这种情况下,我会使用类似以下内容的内容:onmouseover="this.className = this.className + ' AccHover';"
和
onmouseout="this.className = this.className.replace('AccHover', '');"
请参阅示例 http://jsfiddle.net/RgRUN/2/
但我会调用你自己的javascript函数而不是内联编写。
I would use:
onmouseover="this.classList.add('AccHover')"
and
onmouseout="this.classList.remove('AccHover')"
EDIT: Ok I just remembered
classList
doesn't work in IE, I assume that's what you are testing in. In that case I would use something like:onmouseover="this.className = this.className + ' AccHover';"
and
onmouseout="this.className = this.className.replace('AccHover', '');"
See example http://jsfiddle.net/RgRUN/2/
But I would call your own javascript function rather than write inline.