Sunday, 18 August 2013

Difference between .trigger('play') and .play() in jQuery

Difference between .trigger('play') and .play() in jQuery

I'm just wondering about the difference between the jQuery functions
".trigger('play')" and ".play()". I want my website to play a sound when
you press a navigation button. Its supposed to the sound of a HTML5 -tag.
It works when I use this jQuery code:
$('nav ul li a').click(function(){
$('#soundFX').trigger('play');
});
But not this:
$('nav ul li a').click(function(){
$('#soundFX').play();
});
Thank you for answering!

No comments:

Post a Comment