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

237
Visualizações
How to select text on click on text in html?

enter image description here I want when clicked on colours to select them and copy them. They are defined in html like this:

<span>Colour<span>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is not exactly clear from your question what you want to do. From what I understand you need to change color by entering the hex value which can be done simply by DOM manipulations. Below is a basic code that changes color on button clicking.

<html>
<head>
<script>
    var colors = ["red", "blue", "green"];
    var colorIndex = 0;
    function changeColor() {
        var col = document.getElementById("body");
        if( colorIndex >= colors.length ) {
            colorIndex = 0;
        }
        col.style.backgroundColor = colors[colorIndex];
        colorIndex++;
    }
</script>
    <body id='body'>
    <button onclick="changeColor();">Change color</button>
    </body>
</html>

Similarly, you can just use the hex code entered in the input box and set the background/line color accordingly. You will need the help of both js and HTML, and also use if or classes as per your need.

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