这里是我的代码jQuery的`.hover()`方法不适用于`:hover` CSS样式吗?
而且我粘贴它下面:
setTimeout(function(){$("div").hover()}, 1000)
div {
background: grey;
width: 20px;
}
div:hover {
width: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
test
</div>
我想使用jQuery触发hover
事件<div>
,这将扩大其宽度为200px
..但是,在上面的示例中,根本没有任何影响。
有没有人有这方面的想法?谢谢!
'.hover'不工作的方式。但是你可以在CSS中添加一个你拥有':hover'的类,并将其应用到悬停时的元素上。 – putvande
外观[http://stackoverflow.com/questions/10680446/trigger-the-csshover-event-with-js][1] [1]:http://stackoverflow.com/questions/10680446/trigger -the-csshover-event-with-js –