javascript - this.class vs. this.getAttribute('class') -
i have radio button, , when pressed function called, accepts class of button argument. this:
<input class="myclass" type="radio" name="name" value="x" checked="true" onclick="myfunction(this.value, this.getattribute('class'))"></input>
notice in onclick, have this.getattribute('class')
instead of this.class
. tried using this.class kept getting undefined
. this.class
not acceptable thing do? have used this.id
elsewhere in code works fine, reason need use getattribute
when want reference class.
so asking difference between this.class
, this.getattribute('class')
?
use classname current value of class attribute. think reason behind because class reserved word.
Comments
Post a Comment