| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
class toggling problem
ok, basically i want to have something that goes bold when u click it and then when u click it again it changes back to normal.
i want to do this using css for the classes and javascript to change the classes 'onclick'... this is the function i made: function toggleStyleGrey(obj){ var tl = document.getElementById(obj); if(tl.className="menutitlegrey"){ tl.className='menutitlegreyopen'; } else { tl.setClassName='menutitlegrey'; } } it nearly works; when i click it, it goes bold... but then when i click it again it doesnt change back... this is the code for the actaual thing i wanna change: <div class="menutitlegrey" id="yourcats" onclick="toggleStyleGrey('yourcats');"> i think it might be something to do with the fact that i got <div class="menutitlegrey" and the script is only reading that... does anyone else know a way round it or can see what the problem is? thanks Joe |
|
#2
|
|||
|
|||
|
could you not just do
tl.style.font-weight = 'bold'; tl.style.font-weight = 'normal'; |
|
#3
|
|||
|
|||
|
oh, i forgot to end this post, in the end i fixed it by changing the if statement from == to != and swap it around, i dunno why this worked, i just did lol
|
![]() |
| Viewing: Tutorialized Forums > Desktop Programming > Visual C > class toggling problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|