I have a radio button, and when it is pressed a function is called, which accepts the class of the button as an argument. So something like this:
<input class="myclass" type="radio" name="name" value="x" checked="true" onClick="myFunction(this.value, this.getAttribute('class'))"></input>
Notice that in my onClick, I have this.getAttribute('class')
instead of simply this.class
. I tried using this.class but I kept getting undefined
. Is this.class
not an acceptable thing to do? I have used this.id
elsewhere in my code which works fine, but for some reason I need to use getAttribute
when I want to reference class.
So essentially I am asking what is the difference between this.class
and this.getAttribute('class')
?