Possible Duplicate:
Change an element's CSS class with JavaScript
Found lot of topics about this topic, but none helped me. I have:
<div id="text-6" class="block col-228">
Javascript code should add new class fit, so result should be:
<div id="text-6" class="block col-228 fit">
How to do that with javascript?
Try like this:
Important note: You need to be assure,that your
DOM Hierarchyis constructed completely,then try to manipulateDOM Elements. That is why you need to putDOMmanipulation scripts inside of thewindow.onloadcallback, or if you usejQuery, then inside of$(document).readycallback.