YouTip LogoYouTip

Prop Text Value

# HTML DOM Input Text value Property ## Definition and Usage The **value** property sets or returns the value of the text field. **Tips:** You can use the **value** property to get or set the text in a text field. **Note:** If the input type is "text", the value property returns an empty string if no value is set. --- ## Browser Support | Property | !( | !( | !( | !( | !( | |---------|---------|---------|---------|---------|---------| | value | Yes | Yes | Yes | Yes | Yes | --- ## Syntax Return the value property: `inputObject.value` Set the value property: `inputObject.value = text` ## Property Values | Parameter | Description | |-----------|-------------| | text | Specifies the value of the text field | ## Technical Details | Return Value: | A String, representing the value of the text field | |---------------|----------------------------------------------------| | DOM Version | Core Level 1 | --- ## More Examples ### Example 1 Get the value of a text field: ```html ``` ```javascript function myFunction() { var x = document.getElementById("myText").value; alert(x); } ``` ### Example 2 Set the value of a text field: ```html ``` ```javascript function myFunction() { document.getElementById("myText").value = "Hello World"; } ``` --- ## Related Pages HTML tutorial: ( HTML DOM reference: ( JavaScript tutorial: ( --- ## Copyright Notice All Rights Reserved []( --- ## Navigation Menu * ( * [ASP.NET]( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( ## Related Recommendations * ( * ( * ( * ( * ( * ( * [C++ Tutorial]( * ( ## Special Recommendation * ( * ( * ( * ( * ( * ( * ( ## FAQ * ( * ( * ( * ( Β© 2012-2025 Rights Reserved. [ICP Filing Number:](http://www.beian.miit.gov.cn/)
← Met Text SelectProp Text Type β†’