这条简单的线:
$(document).prepend('<div>some text</div>');
从Jquery库产生错误:
TypeError: e is null
错误来自Jquery文件,而不是我的代码。我的函数不使用任何变量“ e”。jQuery版本是1.9.1。我没有发现任何产生此错误的已知问题,但是上面的行是导致此错误的行,因为注释掉该行时不会发生该错误。我可以在其他地方附加元素就好了。如果有区别,则从MouseEnter事件处理程序调用发生问题行的函数。
知道是什么原因造成的吗?
如果您需要更多代码(为了简洁起见,省略了不相关的行):
// Create a delegate event handler:
this.protected.$element.on('mouseenter','.'+this.protected.Prefrences.TriggerClass,function(e){base.eMouseEnter(e,this)});
// Called when the user hovers over the tooltip
ATK.ToolTip.prototype.eMouseEnter = function(e, eventThis){
this.ShowToolTip($(eventThis));
}
ATK.ToolTip.prototype.ShowToolTip = function($TipElement){
$(document).prepend('<div>sometext</div>'); // Triggers "TypeError: e is null" ?!
}
您正在尝试将div
元素添加到的开始document
,而不是此:
$(document).prepend('<div>sometext</div>');
尝试做:
$(document.body).prepend('<div>sometext</div>');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句