I'm with a problem embedding one audio object in two different divs. The javascript only appends the object on the first called div, lefting the other one empty. How can i append the same object in two different divs?
I'm working on a web app project and those divs represents the orientation of the device. When i turn on a side, the other div hides (e.g 开发者_StackOverflowI'm in portrait view - landscape div hides).
Here's my code:
var audioPlayer = new Audio();
audioPlayerPort.controls="controls";
audioPlayerPort.setAttribute('src','mysource');
$('#playerAudioLandscape').append(audioPlayer);
$('#playerAudioPortrait').append(audioPlayer);
Think about it; how can one element exist in two places at once? What you should do is make a copy and insert one in each element.
精彩评论