开发者

Audio player object appending using jquery problem

开发者 https://www.devze.com 2023-03-29 07:43 出处:网络
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 t

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号