I am using this changing color script by j08691:
function flash() {
var text = document.getElementById('foo');
text.style.color = (text.style.color=='red') ? 'green':'red';
}
var clr = setInterval(flash, 1000);
I want to call the <body>
tag and <a>
tag from the CSS not an id.
For the <body>
tag I did this and it works:
function flash() {
var text = document.body;
text.style.color = (text.style.color=='black') ? 'white':'black';
}
var clr = setInterval(flash, 1);
But it isn't working with the <a>
tag. I tried variations like:
var els = document.getElementsByTagName('a');
var links = document.getElementsByTagName('a');
instead of var text = document.getElementById('a');
and replacing text.style.color with links[i].style.color or links.style.color
But I'm not quite sure what I'm doing there.
I want to change the colors of all links at once.
Aucun commentaire:
Enregistrer un commentaire