Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
Changing Div content with innerHTML

I've read through many other questions on this but none seem to solve my problem.

I have created a div element which houses an icon from fontawesome. It's a media player icon where i use an if/else argument to change from PLAY to PAUSE and back again. Without using the fontawesome element it works but i like the icon. I've also looked up using jquery instead but it's a little beyond my knowledge.

It's the i class="fa fa-stop" aria-hidden="true" it doesn't like.

<script language="javascript">
        function chPlay2() {
            
    if (document.getElementById("player").title =="Toggle Play") 
    {
        audio.play();
        document.getElementById("player").title = "Toggle Stop";
        document.getElementById("player").innerHTML = "&nbsp;<i class="fa fa-stop" aria-hidden="true"></i>";
    }
    else
    {
        audio.pause();
        document.getElementById("player").title = "Toggle Play";
        document.getElementById("player").innerHTML = "&nbsp;<i class="fa fa-play" aria-hidden="true"></i>";
    }
}
</script>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You should use like this-

document.getElementById("player").innerHTML = '&nbsp;<i class="fa fa-stop" aria-hidden="true"></i>';

Just replace the double quotes with single quotes.

about 4 years ago · Juan Pablo Isaza Relatório

0

You have a double qoute inside your string literals. Try using the ` for string template or escape your double qoutes using \ (the escape character). it would look something like this

document.getElementById("player").innerHTML = `&nbsp;<i class="fa fa-stop" aria-hidden="true"></i>`;

or alternatively,

document.getElementById("player").innerHTML = "&nbsp;<i class=\"fa fa-stop\" aria-hidden="true"></i>";

This is true for many languages so you might want to keep this in mind.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda