JavaScript Reference/Javascript Properties/defaultValue

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

"defaultValue" Example

    
<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>



"defaultValue" is applied to

+----------------+--------------------------------------------------------------+
| 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>                                                    |
+----------------+--------------------------------------------------------------+



"defaultValue" Syntax and Note

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