错误:ReferenceError:未定义事件
Error: ReferenceError: event is not defined
请使用以下代码提供帮助。
我在firefox和ie.上收到"事件未定义"错误
问题似乎与event.prventDefault()有关;
这个css只是关闭了下拉菜单
<style type="text/css">
.dropdown {
display: none;
opacity: 0;
}
</style>
jquery
自定义javascript
<script type="text/javascript">
$( document ).ready(function(){
jQuery('.download-dropdown > a').click( function() {
event.preventDefault();
var $this=jQuery(this);
if (!$this.parent().hasClass('active')) {
var top=$this.parent().offset().top;
var left=$this.parent().offset().left;
jQuery('body').append($this.parent());
$this.parent().addClass('active');
$this.parent().css({ 'position': 'absolute',
'top': top,
'left': left,
'z-index': 999});
$this.parent().children('.dropdown').animate({ 'opacity': '1','height': 'toggle'});
$this.parent().animate({'height': '400'});
window.dropdown=$this;
}
else {
$this.parent().css({ 'position': 'relative',
'top': 'inherit',
'left': 'inherit',
'z-index': 1});
$this.parent().removeClass('active');
jQuery('article.contact-download > div > section > div').append($this.parent());
$this.parent().children('.dropdown').animate({ 'opacity': '0','height': 'toggle'});
$this.parent().animate({'height': '45'});
}
});
});
</script>
这是html
<article class="contact-download" data-background-height="60">
<section data-speed="0">
<div>
<div class="download-dropdown" style="height: 60px; position: relative; z-index: 1; top: inherit; left: inherit; display: inline-table"> <a style="padding-left: 25px; text-decoration:none; " href="#">click to see more</a>
<div class="dropdown">
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</div>
</div>
</div>
</section>
</article>
您需要将is设置为函数参数:
jQuery('.download-dropdown > a').click( function(event) {
// event is defined now __^__
相关文章:
- $window.ga在AngularJS事件中未定义
- 事件在加载之前时的未定义位置
- Razor Dropdown onchange事件未触发始终未定义
- ui.columnIndex在igGridHiding-columnShowing事件中未定义
- ReferenceError:事件未在Firefox中定义错误
- 包含的javascript源代码通过PHP,onmousemove事件,函数未定义
- InAppBrowser事件.url始终未定义
- 自定义jQuery插件:事件未按预期运行
- 事件未定义 火狐.
- 事件未定义错误在 javascript 中只有 Firefox
- 事件未定义错误,仅在火狐中
- 事件未定义 JavaScript Firefox (JSON)
- JS Revearing Pattern事件未定义问题
- 事件未定义 FF
- ReferenceError:事件未定义firefox d3.js
- 为什么使用a.c click时事件未定义?
- "事件未定义“;在firefox中
- 类型错误:firefox中关于javascript的事件未定义
- jQuery onkeyup事件:未定义扫描
- IE8中的图像加载事件;事件未定义,这是“窗口”对象