I'm trying to manually trigger a mousemove
event with jQuery. Demo in this fiddle http://jsfiddle.net/qJJQW/
From other similar posts on Stack Overflow it seems that this should work. Why isn't it?
Use jQuery to bind the mousemove event:
$(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);
}
Your updated fiddle.
jQuery's trigger()
only triggers event handlers set with 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);
}
FIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With