I suggest not using the font tag, use the span tag instead. Here is a working example in JSFiddle .
HTML
<span id="text">text</span>
Javascript
var text = document.getElementById('text'); text.addEventListener("load", init(), false); function changeColor() { text.style.color = "#F00"; } function init() { setTimeout(changeColor, 3000); }
Here is a brief description of each JavaScript function that I used in the code.
getElementById
Returns a reference to the DOM element by ID .
For more information about this feature, you can contact here.
For alternate features, check this URL
In my example, I went through 'text' , which is the ID my span tag.
addEventListener
Registers the specified listener in the called EventTarget , which can be any object that supports events .
For more information about this feature, you can contact here.
In my example, I registered init() listener in a text object that will be called in the load event.
Settimeout
Calls a function or executes a piece of code after the specified delay.
For more information about this feature, you can contact here.
In my example, I passed the changeColor() function as an argument, so it will be called after a 3 second delay ( Note: the delay is in milliseconds ).
So here is the final process:
- Item uploaded
init() function was called- The setTimeout () function was called
- 'changeColor () function was called after 3 seconds
- Item color changed
source share