Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!