简体   繁体   English

jQuery如何将:hover添加到CSS样式表

[英]Jquery how to add :hover to css style sheet

This is the CSS I like to convert to jQuery code: 这是我想转换为jQuery代码的CSS:

BUTTON:hover .buttonTextDIV {
background-color: #FFFFFF;
border-right: 4px solid #d1dbea;
border-bottom: 2px solid #d1dbea;}

I use a filter in 4.01 Transitional and I have a problem with the $().hover event where the effects of the filter are negated by the onmouseleave function which $().hover uses to "emulate" the css :hover option when it leaves the object. 我在4.01 Transitional中使用了一个过滤器,并且$()。hover事件有一个问题,该过滤器的作用被onmouseleave函数否定,该函数在$()。hover用于“模拟” css:hover选项时离开对象。

So I need to "hardcode" button:hover .buttonTextDIV using jQuery. 所以我需要使用jQuery“硬编码” button:hover .buttonTextDIV。

I want to specifically add this to each element seperate using : $(".buttontext").each(function(){} 我想使用$(“。buttontext”)。each(function(){}将其专门添加到每个单独的元素中

Is there a way to do this? 有没有办法做到这一点?

I don't want people telling me not to use 4.01, if you intend on doing that please move on to the next question. 我不希望有人告诉我不要使用4.01,如果您打算这样做,请继续下一个问题。

JavaScript cannot directly define or edit pseudo classes of CSS. JavaScript无法直接定义或编辑CSS的伪类。 Not unless you edit the CSS directly. 除非您直接编辑CSS,否则不可以。 But if hover() is not working for you (you didn't indicate why?), I can only suggest that you try manually defining your own events: 但是,如果hover()对您不起作用(您没有说明原因?),我只能建议您尝试手动定义自己的事件:

.mouseenter() .mouseenter()
.mouseleave() .mouseleave()

.mouseover() 。鼠标移到()
.mouseout() .mouseout()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM