Prev Demo
jQuery
>
.Val() - Get Or Set The Value Of An Element
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <style> .class1{ background-color:green; color:yellow; } </style> </head> <body> <p class="class1">TechFunda.com code editor</p> <input type="button" id="btnToggleClass" value="www.Techfunda.com" /> <br/> <br/> <p>Hence it was showing the element text in VALUE attribute as a ALERT.</p> <script> alert($("#btnToggleClass").val()); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output