Hi Everybody,
I'd be grateful if you could help me out. I need to change the CSS by changing the id when a link is clicked.
The id is in the body tag and by default it is named 'first'. i.e
[ICODE]<body id="first">[/ICODE].
If I click on the link named 'Change id to Second', this should change to [ICODE]<body id="Second">[/ICODE].
If I further click on the link named "Change id to Second" this should change to
[ICODE]<body id="Third">[/ICODE].
My code below works (I have stripped this down to make sense), but only when I click one of the links for the first time. If I am to click the second/ third link, nothing happens:
Any help will be greatly appreciated.Code:<html> <head> <script type="text/javascript"> function changeFirst() { document.getElementById('blanky').id = 'first'; document.getElementById('second').id = 'first'; document.getElementById('third').id = 'first'; } function changeSecond() { document.getElementById('blanky').id = 'second'; document.getElementById('first').id = 'second'; document.getElementById('third').id = 'second'; } function changeThird() { document.getElementById('blanky').id = 'third'; document.getElementById('first').id = 'third'; document.getElementById('second').id = 'third'; } </script> </head> <body id=first><!-- I need to change this id --> <p>Hello, the id above should change when the following links are clicked</p> <a onclick="changeFirst()">Change id to First</a> <a onclick="changeSecond()">Change id to Second</a> <a onclick="changeThird()">Change id to Third</a> </body> </html>
Cheers


Reply With Quote
Bookmarks