Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda