Here is my code
And I pasted it below:
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>
I want to use jQuery to trigger the hover event of <div>, which will expand its width to 200px.. However, in the example above, there is no effect at all..
Does anyone have ideas about this?
.hoverdoesn't work that way. But you could just add a class where you have your:hoverin the CSS and apply that to your element on hover.