模拟悬停在元素jquery函数上[重复]

问题描述 投票:-1回答:2

这个问题在这里已有答案:

我想在jquery中创建一个函数,它模拟页面上特定元素的onMouseOver事件。然后用这样的html按钮调用它

onclick="myFunction()"
I've been searching for a solution now for a while and just couldn't figure it out. Do anyone have solution? or is it easier to make javascript? Kind regards
javascript jquery html mouseover simulate
2个回答
0
投票

我不明白,会是那样的吗?我将鼠标放在悬停或悬停事件上,以便在需要时更轻松。

<div class="wrapper" style="width:200px;height:200px;background:red">

</div>
<button id="myButton">my button</button>

__

$('.wrapper').hover(function(){
  console.log('mouse in');
},function(){
  $('#myButton').click();
});

$('#myButton').click(function(){
  alert('clicked button')
})

0
投票
$("#yourid").on('mouseover', function() {
   // do something
});
© www.soinside.com 2019 - 2024. All rights reserved.