javascript - Play sound in jquery mobile on different pages -
i need play sound in background repeat time - background music. have added <audio>
tag in page html , added event
$("#audio-player").on('ended', function() { //play again }
in pageinit
event of page. , works, music should continue when navigate other page, , not sure how make this. appreciate help.
you use ajax load new page. use jquery's load() load #content part of new page #content div of current page.
html
<header> <audio controls> <source src="horse.ogg" type="audio/ogg"> </audio> </header> <a href="page2.html">page 2</a> <div id="content"> page 1 content </div> </body> </html>
javascript / jquery
$('a').click(function(e){ e.preventdefault(); var target = $(this).attr('href'); $('#content').load(target + ' #content'); });
Comments
Post a Comment