I want that the jquery animation(of the div) will start when the sound1 and sound2 will loaded. Now its start the animation and after a few seconds its start the audio.
Edit- thx for yousef for the jsfiddle-
http://jsfiddle.net/mohamedyousef1980/r4cs6mqe
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<button id="play" onclick="playMusic()" type="button">Play music</button>
<script>
$(document).ready(function(){
$("#play").click(function(){
$("div").animate({left: '250px'},1000);
$("div").animate({left: '10px'},100);
});
});
function playMusic() {
sound1 = new Audio('http://www.thesoundarchive.com/starwars/Chewie-chatting.wav');
sound2=new Audio('http://www.thesoundarchive.com/starwars/return/jabba-the-hutt-laughing.wav');
sound1.mediaGroup = 'soundGroup';
sound2.mediaGroup = 'soundGroup';
sound1.play();
sound2.play();
}
</script>
</head>
<body>
<div style="background:#000;height:70px;width:10px;position:absolute;"></div>
</body>
</html>