我正在开发一个大项目,需要将事件重新发送到页面。
让我解释一下:
一个盒子<div>
位于图像 <img>
像这样:
<div>
<div id="box"></div>
<img>
</div>
一旦用户点击box
,它移动到另一个位置,但图像必须同时单击,这两个元素必须同时单击。 (解释起来很长)
也许可以将事件重新发送到同一位置,或者可以在当前鼠标位置创建另一个事件..
最佳答案
你可以试试这个:
$('selectorA').on('eventType', function(e){
$('selectorB').trigger(e); // the SAME event
});
没有 jQuery:
element.onSomeEvent = function(e){
otherElement.dispatchEvent(e); // the SAME event
};
关于javascript - 将事件重新发送到页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14022809/