TypeError: e is undefined - javascript
TypeError: e is undefined - javascript
所有其他浏览器都能正常工作。然而,当firefox尝试执行以下代码时:
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
它崩溃,控制台显示以下错误:TypeError:e是未定义的
编辑1:
function clickInactiveTab() {
$(this).attr({class: "activeTab"});
$(".inactiveTab").hide();
}
function clickX() {
$(this).parent().attr({class: "inactiveTab"});
$(".inactiveTab").show();
if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
它所做的是,在单击时更改div的样式,并从类中隐藏所有其他div。当有人点击div内部的x时,它应该将样式改回并显示隐藏的div。
e未定义,因此这将是错误
function clickX(e) { //e needs to be in the arguments as long as the event is attached properly, this will work.
$(this).parent().attr({class: "inactiveTab"});
$(".inactiveTab").show();
e = e || window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
}
如果使用jQuery附加事件,则没有理由检查事件或stopPropagation。
相关文章:
- JavaScript”;.方法“;返回undefined
- 将对象的列表c#传递给javascript:undefined变量时出错
- Javascript/JSON警报返回Undefined
- Javascript:firstChild对象返回undefined
- 使用在函数外部声明的变量的 Javascript 返回值 + undefined
- JavaScript undefined不是一个函数(使用splice函数)
- jQuery/JavaScript Undefined Function Error
- JavaScript undefined-safety-pattern 是否同样好
- Javascript undefined innerHTML
- Javascript: Undefined
- Javascript undefined不是函数
- 要使用其中“org.mozilla.javascript.Undefined@c91f0d"在Java脚本中出
- JavaScript undefined?
- Javascript Undefined
- Javascript !undefined gives true?
- javascript undefined nodelist returns true
- Javascript:“undefined"变量的值
- Javascript Undefined with PHP & MySQL
- Javascript: undefined &For循环问题
- JavaScript `undefined` vs `void 0`