[英]How to trigger a mouse move event from jQuery
I'm trying to manually trigger a mousemove
event with jQuery.我正在尝试使用 jQuery 手动触发
mousemove
事件。 Demo in this fiddle http://jsfiddle.net/qJJQW/演示在这个小提琴http://jsfiddle.net/qJJQW/
From other similar posts on Stack Overflow it seems that this should work.从 Stack Overflow 上的其他类似帖子来看,这似乎应该有效。 Why isn't it?
为什么不是?
Use jQuery to bind the mousemove event:使用 jQuery 绑定 mousemove 事件:
$(function () {
$("#test").on("mousemove", youCantHandleTheFunc);
$('#button').click(function () {
$('#test').trigger('mousemove', {type:'custom mouse move'});
});
});
function youCantHandleTheFunc (e,customE) {
if (customE != undefined) {
e = customE;
}
$('#result').html(e.type);
}
jQuery's trigger()
only triggers event handlers set with jQuery ? jQuery 的
trigger()
只触发用 jQuery 设置的事件处理程序?
$(function(){
$('#test').on('mousemove', youCantHandleTheFunc);
$('#button').click(function(){
$('#test').trigger('mousemove',{type:'custom mouse move'});
});
});
function youCantHandleTheFunc(e,customE){
if (customE!=undefined){
e=customE;
}
$('#result').html(e.type);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.