ReferenceError:事件没有在Firefox中定义 [英] ReferenceError: event is not defined in Firefox

查看:214
本文介绍了ReferenceError:事件没有在Firefox中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

它在Chrome和IE上工作,但在Firefox中出现这个错误:

  ReferenceError:未定义事件$(#tooltip)。animate({left:
event.clientX,top:event.clientY} );

如何解决这个问题?

$ b $ pre $ j $ j $('selector')。on('click',function (evt){
jQuery(#tooltip)。animate({left:evt.clientX,top:evt.clientY});
});


I am using this function:

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

Its working on Chrome and IE but in Firefox I get this error:

ReferenceError: event is not defined $("#tooltip").animate({ left:
event.clientX, top: event.clientY });

How can i solve this?

解决方案

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 });
});

这篇关于ReferenceError:事件没有在Firefox中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆