Jorge Ben Jorge Ben - 1 year ago 359
jQuery Question

Error: ReferenceError: event is not defined

Please help with the following code.

I am getting "event is not defined" error on firefox and ie.

The issue appears tobe with event.preventDefault();

this css just turns off the drop-down menu

<style type="text/css">
.dropdown {
display: none;
opacity: 0;


custom javascript

<script type="text/javascript">

$( document ).ready(function(){

jQuery('.download-dropdown > a').click( function() {
var $this=jQuery(this);
if (!$this.parent().hasClass('active')) {
var top=$this.parent().offset().top;
var left=$this.parent().offset().left;
$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'});
else {
$this.parent().css({ 'position': 'relative',
'top': 'inherit',
'left': 'inherit',
'z-index': 1});
jQuery(' > div > section > div').append($this.parent());
$this.parent().children('.dropdown').animate({ 'opacity': '0','height': 'toggle'});
$this.parent().animate({'height': '45'});




This is the html

<article class="contact-download" data-background-height="60">
<section data-speed="0">
<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">
<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>

Answer Source

You need to set is as a function parameter:

jQuery('.download-dropdown > a').click( function(event) {
    // event is defined now                      __^__
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download