scriptygoddess

01 Dec, 2007

Change class name assignment with javascript

Posted by: Jennifer In: Javascript

Example:
<div id="mydiv" class="current">Content</div>

To change class assignment:
document.getElementById('mydiv').className = 'notcurrent';

To remove the class assignment:
document.getElementById('mydiv').className = '';

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

1 Response to "Change class name assignment with javascript"

1 | Tom-Eric

December 3rd, 2007 at 1:12 am

Avatar

To break the example:
<div id="mydiv" class="current some-other-class">Content</div>

Comment Form

Featured Sponsors


  • Curt: If anyone comes across this with similar issues I was able to sort out the pagination issues painlessly with easyCommentsPaginate from http://www.mush
  • Christopher: Yeah, it is indeed hard to do. And something remains elusive about why the pagination never worked. I tried everything I could find. Regardless, I
  • Jennifer: Hi Christopher, always hard to bug test stuff like that remotely. Sorry those didn't help. Glad you found a solution though :)

About


Advertisements