ReferenceError: event is not defined in Firefox

后端 未结 2 1412
闹比i
闹比i 2020-12-21 10:25

I am using this function:

$(\"#tooltip\").animate({ left: event.clientX, top: event.clientY });

Its working on Chrome and IE but in Firefox

2条回答
  •  误落风尘
    2020-12-21 10:35

    You appear to be trying to use the odd global event object that is a legacy of the 4.0-browser-era Microsoft event model. Don't. Use the standard event object instead. It will be the first argument to your event handler function.

    jQuery('selector').on('click', function (evt) {
        jQuery("#tooltip").animate({ left: evt.clientX, top: evt.clientY });
    });
    

提交回复
热议问题