I'm fairly new when it comes to Javascript and I'm trying to create an audio playlist for an <audio>
tag.
I'm currently stuck on what should be quite a simple stage of the process where I want the anchor's click event to be prevented to stop it from taking you to an new page to play the audio.
window.onload = function(){
playlist = $('#playlist');
playlist.find('a').click(function(e){
$(e).preventDefault();
alert('event prevented');
});
};
I keep getting the below error. I've checked and double checked the syntex but can't seem to get this to run. I must be missing something simple.
Uncaught TypeError: Object [object Object] has no method 'preventDefault'
I've tried $(this).preventDefault();
and even $('#playlist a').preventDafault();
Any help would be greatly appreciated.
change
$(e).preventDefault();
to
e.preventDefault();