How to change the color in this script

Joined
Sep 9, 2022
Messages
1
Reaction score
0
Hi,

I have a download wait timer code in my wordpress site and i want to change the color of text "you can download the file in 20 seconds".
This message shows in black and it just merge with other text, i want it in a different color so that visitors can see that easily.

<script>
var downloadButton = document.getElementById("download");
var counter = 20;
var newElement = document.createElement("p");
newElement.innerHTML = "You can download the file in 20 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>
 
Joined
Mar 11, 2022
Messages
226
Reaction score
32
Wrong section. This is PHP but you're asking for Javascript.

Use code tags please. Otherwise it's hard to read.

Change color of a element in Javascript
Code:
document.getElementById('myelement').style.color='#FF0000'; //for red
Change background color of a element in Javascript
Code:
document.getElementById('myelement').style.backgroundColor='#00FF00'; //for green
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,707
Messages
2,569,343
Members
44,635
Latest member
Matt231

Latest Threads

Top