Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to get the value through class in javascript.
like we get through ID which is
C#
document .getElementById("<%=txtName.ClientID%>").value
Posted
Comments
F-ES Sitecore 25-Nov-15 4:13am    
You'll need to explain your question more thoroughly. When you say "class" do you mean you want the css class of the txtName element? Or you want the property of a .net class from your server-side code?

Hi,

var x = document.getElementsByClassName("example");
 
Share this answer
 
Comments
MS Rumi 25-Nov-15 4:06am    
its not working ..
Thanks7872 25-Nov-15 5:05am    
What does it mean by not working?
Using class name you will get a array of elements cause your page may have multiple elements using same css class.
JavaScript
var x = document.getElementsByClassName("yourClassName");
var i;
for (i = 0; i < x.length; i++) {
   var val =  x[i].value;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900