Wuu Posted December 28, 2008 Report Share 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 Link to comment Share on other sites More sharing options...
xPtv45z Posted December 28, 2008 Report Share Posted December 28, 2008 :) Un kur problēma izmēģināt pirms postot? Link to comment Share on other sites More sharing options...
codez Posted December 28, 2008 Report Share 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')) } Link to comment Share on other sites More sharing options...
Wuu Posted December 28, 2008 Author Report Share Posted December 28, 2008 codez senx ,es par kaut kādu ciklu domāju ,bet JS nemāku vispār :D Link to comment Share on other sites More sharing options...
Wuu Posted December 30, 2008 Author Report Share Posted December 30, 2008 Uz IE6 nestrādā ne mans ne codez kods ,ir citas iespējas? Link to comment Share on other sites More sharing options...
codez Posted December 30, 2008 Report Share Posted December 30, 2008 document.getElementById("button"+i).className='manaklase'; Link to comment Share on other sites More sharing options...
Wuu Posted December 30, 2008 Author Report Share Posted December 30, 2008 Paldies! Link to comment Share on other sites More sharing options...
Recommended Posts