Wuu Posted December 28, 2008 Report Posted December 28, 2008 (edited) 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 December 28, 2008 by Wuu
xPtv45z Posted December 28, 2008 Report Posted December 28, 2008 :) Un kur problēma izmēģināt pirms postot?
codez Posted December 28, 2008 Report Posted December 28, 2008 kaut kā tā nebūs īsāk? for(i=1;i<=4;i++){ document.getElementById("button"+i).setAttribute("class", "img_button"+(i==page?'':'_closed')) }
Wuu Posted December 28, 2008 Author Report Posted December 28, 2008 codez senx ,es par kaut kādu ciklu domāju ,bet JS nemāku vispār :D
Wuu Posted December 30, 2008 Author Report Posted December 30, 2008 Uz IE6 nestrādā ne mans ne codez kods ,ir citas iespējas?
codez Posted December 30, 2008 Report Posted December 30, 2008 document.getElementById("button"+i).className='manaklase';
Recommended Posts