How do I change the color of a text part?

<script>
var downloadButton = document.getElementById("download");
var counter = 10;
var newElement = document.createElement("p");
newElement.innerHTML = "You can download the file in 10 seconds.";
var id;
downloadButton.parentNode.replaceChild(newElement, downloadButton);
id = setInterval(function() {
counter--;
if(counter < 0) {
newElement.parentNode.replaceChild(downloadButton, newElement);
clearInterval(id);
} else {
newElement.innerHTML = "You can download the file in " + counter.toString() + " seconds.";
}}, 1000);
</script>

    shamiurrahman Please write the code? I do not understand

    You'll need to, because you'll be responsible for it.

    Something I've learned from years on these forums is that copy-and-paste code never works.

    The first example on the page maxxd links shows how JavaScript can add style to an HTML element. You have an HTML element there called newElement and adding styling to that is what you're asking for.

    Unless by "text part" you mean a part of the text you're adding. If that's true then you'll need to use more than just a p element. You will also need a span element around the part you want to colour, and then add the style to that.

      Write a Reply...