JavaScript Reference/Javascript Properties/defaultValue

Материал из Web эксперт
Перейти к: навигация, поиск

"defaultValue" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

   var m = document.getElementById("myB").defaultValue;
   alert("The value of this element is: "+"""+m+"""); 

} </script> <input id="myB" type="button" value="Click here" onclick="function1();"> </body> </html>


     </source>
   
  


"defaultValue" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="hidden"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | |<textarea> | +----------------+--------------------------------------------------------------+

     </source>
   
  


"defaultValue" Syntax and Note

   <source lang="javascript">

Note: Read-only property. Returns the content of the element when the page is loaded.

Syntax:

document.getElementById("elementID").defaultValue document.all.elementID.defaultValue // IE only


     </source>