hey i have a jquery function that is triggered on an anchor’s onclick event the function is as follows:
function dropDown(subid, e) {
e.preventDefault();
var sub = '#' + subid;
// hide all submenus first
$('.subnav').css({'display' : 'none'});
//Show the Current Subnav
$(sub).css({'display' : 'block'});
}
this is how i am tring to trigger it :
<a href="#!" onclick="dropDown('sn_cities')" >Cities</a>
However i am getting this error: e is undefined
i want to cancel the default onclick event of the anchor link, any help would be appreciated.
You’re not passing the event object (or anything at all) to the
eparameter of the function. Try this:I’d be inclined to lose the inline JS altogether though: