jquery preventDefault not working
Why is my below preventDefault not working? can't seem to figure it out on this one
$(function() {
$('a.action-link').bind('click', function(e){
if(!$(this).hasClass('active')) {
e.preventDef开发者_JAVA百科ault();
$('#guts').fadeTo(333, 0.2);
$('ul#slider').fadeOut(333, 'easeOutExpo', function() {
$(this).fadeIn(333, 'easeInExpo');
});
return false;
});
}
});
Your brackets/parentheses don't match up. I'm not sure how any of it could work.
$(function() {
$('a.action-link').bind('click', function(e){
if(!$(this).hasClass('active')) {
e.preventDefault();
$('#guts').fadeTo(333, 0.2);
$('ul#slider').fadeOut(333, 'easeOutExpo', function() {
$(this).fadeIn(333, 'easeInExpo');
});
return false;
}
});
});
Seems that was only a syntax mistake:
return false;
});
}
});
to
return false;
}
});
});
This works as in the fiddle:
http://jsfiddle.net/UnahA/1/
精彩评论