OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
Assign New Class to Object
This page's ID:
11111
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
You've got the right idea; just two problems: the first problem isn't really a *huge* deal, but if you want to do things right, use document.getElementById('myImage') instead of document.myImage the second problem is that "class" is a reserved keyword in JavaScript, so to get to the class of an element, you use "className" instead. The final statement is: document.getElementById('myImage').className = 'class2'; Note that it is possible to assign an element to multiple classes by using a space-separated list (class="class1 class2 class3"). Because of this, simply assigning a new value to className can be a bad idea since it will overwrite all of the classes assigned to an element with the single class that you're assigning. But if you're only using this on specific pieces of code where you know that's not a problem, then you don't really have to worry about it.
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »