I'm putting a player on my site. As I do not know much about JS / JQ, I got a simple template on the internet, I set up a layout and I set the script to my liking as far as I could.
Now I got stuck on something that I thought was super easy, but I've tried it in many ways without success. What I want is to "clone" the text that is in div
(in this case the name of the song, from [currentIndex]
) to another div
(in the player bar).
Here I am leaving the part of the script that I think has the possibility to do this so you better understand his logic. Look at my last attempt:
Carousel.prototype.go_to = function( index, currentIndex )
{
if (currentIndex != index) {
index = index%this.count;
if (index < 0)
index = index + this.count;
this.$.faicha[currentIndex].classList.remove('ativo');
this.$.faicha[index].classList.add('ativo');
this.$.musica[0].setAttribute('src', 'som/' + index + '.mp3');
/*Aqui abaixo minha tentativa*/
this.$.nomedamusica[0].clone().appendTo(".nomedamusicaaqui");
this.changeMusic();
this.index = index;
}
};
.nomedamusica
comes from the class where it has the name of the song. E .nomedamusicaaqui
is the class of div
where the text should be "pasted."