JavaScript - get element's class
Posted: Fri Oct 06, 2006 4:09 am
I really don't know JavaScript but I'm trying to edit some extension for Vanilla so I need some help, thanks in advance
Let's say that this is some part from my source:
Now, I have a JavaScript variable targetId which holds the name of the element's id. So: targetId = 'my_id'.
How can I get, let's say into another variable, the class of the element which its id is held by targetId?
Something like this:
After the above line, my_class should hold the string 'my_class'.
Let's say that this is some part from my source:
Code: Select all
<li id="my_id" class="my_class">How can I get, let's say into another variable, the class of the element which its id is held by targetId?
Something like this:
Code: Select all
var my_class = some_made_up_function(targetId);