Jump to content
php.lv forumi

Java onclik maina clasi


Wuu

Recommended Posts

	function changeClass(page){
	if(page == 1){ document.getElementById("button1").setAttribute("class", "img_button"); } else { document.getElementById("button1").setAttribute("class", "img_button_closed"); }
	if(page == 2){ document.getElementById("button2").setAttribute("class", "img_button"); } else { document.getElementById("button2").setAttribute("class", "img_button_closed"); }
	if(page == 3){ document.getElementById("button3").setAttribute("class", "img_button"); } else { document.getElementById("button3").setAttribute("class", "img_button_closed"); }
	if(page == 4){ document.getElementById("button4").setAttribute("class", "img_button"); } else { document.getElementById("button4").setAttribute("class", "img_button_closed"); }
}

 

Man ir 4 linki tad iedarbini šito šādi

 

<a href='' onclick="changeClass(1);">1</a>
<a href='' onclick="changeClass(2);">2</a>
<a href='' onclick="changeClass(3);">3</a>
<a href='' onclick="changeClass(4);">4</a>

 

Vai būs pareizi?

Edited by Wuu
Link to comment
Share on other sites

×
×
  • Create New...