Use prop('defaultValue') to return attribute value - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:prop

Description

Use prop('defaultValue') to return attribute value

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.3.js"></script> 
  <script type="text/javascript">
    $(function(){/*w w  w .  ja va2s .c o m*/
var x = $( '#q' ).prop( 'defaultValue' );
console.log( x );
    });

      </script> 
 </head> 
 <body> 
  <form action="#"> 
   <input id="q" class="autoclear blur" value="search" name="q" type="text"> 
  </form>  
 </body>
</html>

Related Tutorials