如何从 jQuery 触发鼠标移动事件

hof*_*lie 5 html javascript jquery mousemove jquery-events

我正在尝试mousemove使用 jQuery手动触发事件。演示在这个小提琴http://jsfiddle.net/qJJQW/

从 Stack Overflow 上的其他类似帖子来看,这似乎应该有效。为什么不是?

kar*_*m79 4

使用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);
}
Run Code Online (Sandbox Code Playgroud)

你更新的小提琴。