2
I’m organizing a player to put on my website. As I don’t know much about JS/JQ, I took a simple model on the internet, put together a layout and adjusted the script to my liking as far as I could.
Now I’ve stumbled onto 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 a div
(in the case of the name of the song, [currentIndex]
) to another div
(in the player bar).
Here I am leaving the part of the script that I consider has the possibility to do this so you understand better 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. And .nomedamusicaaqui
is the class of div
where the text should be "pasted".
You want to just get the text or the whole div?
– Sam
only the text! but the div only has the same text
– Thiago Soubra
Tries
$(".nomedamusicaaqui").append(this.$.nomedamusica[0].text());
– Sam
@dvd worked not bro... and part of the function gets corrupted :|
– Thiago Soubra