Here i am explaining how to get class name through JavaScript using id and u can also change class name.
How do get the class name through JavaScript given no id with this span.
Like: This is a simple span, here i am getting class name using id of span.
var className=document.getElementById("xyz").className; if(className=="xyz") { alert(className); } else { document.write("This is not a valid class name"); alert(className); }
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.