yaseenyahya
11-09-2012, 08:52 PM
I have a 5 text in white color in <anchor tag> when i click 1 it changes to "orange" And when i click 2...except this 2 al changes to white..and so on...is there any shortest way to do it or another way.. =)
window.onload = function(){
var as = document.getElementsByTagName("a");
as[0].onclick = function(){
this.style.color = "orange";
as[1].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[1].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[2].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[1].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[3].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[1].style.color = "white";
as[4].style.color = "white";
}
as[4].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[1].style.color = "white";
}
};
window.onload = function(){
var as = document.getElementsByTagName("a");
as[0].onclick = function(){
this.style.color = "orange";
as[1].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[1].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[2].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[1].style.color = "white";
as[3].style.color = "white";
as[4].style.color = "white";
}
as[3].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[1].style.color = "white";
as[4].style.color = "white";
}
as[4].onclick = function(){
this.style.color = "orange";
as[0].style.color = "white";
as[2].style.color = "white";
as[3].style.color = "white";
as[1].style.color = "white";
}
};