I may sound stupid but I am trying to get the value of a class attribute. But it is spitting undefined, while rest of the properties are working fine. I searched on stackoverflow but those are using byClassName or byTagName but I want byElementId JSBIN Link
This is the function
(function() {
var fname = document.getElementById("fname");
console.log(fname.id); //fname
console.log(fname.name); //firstName
console.log(fname.class); //undefined
})();
HTML
<input type="text" name="firstName" id="fname" class="gotcha">