YouTip LogoYouTip

Prop Search Value

HTML DOM Input Search value Property

HTML DOM Input Search value Property

HTML DOM Input Search value Property

-- Learning not just skills, but dreams!

JavaScript Reference

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

HTML DOM Reset Object

HTML DOM Submit Object

Deep Dive

  • Computer Science
  • Web Services
  • Programming
  • Scripting
  • Programming Languages
  • Development Tools
  • Scripting Languages
  • Web Design and Development
  • Software
  • Web Service

Input Search value Property

Image 8: Input Search Object Reference Input Search Object

Example

Change the value of a search field:

document.getElementById("mySearch").value = "Favorite Cars";

Try it yourself Β»


Definition and Usage

The value property sets or returns the value of the value attribute of a search field.

The value property describes the value entered by the user, or the default value, or the value entered by a script.


Browser Support

Image 9: Internet ExplorerImage 10: FirefoxImage 11: OperaImage 12: Google ChromeImage 13: Safari

The value property is supported in all major browsers.


Syntax

Return the value property:

searchObject.value

Set the value property:

searchObject.value=text

Property Values

Value Description
text Specifies the initial (default) value of the search field.

Technical Details

Return Value: A String, representing the value of the search field

More Examples

Example

Get the value of a search field:

var x = document.getElementById("myRange").value;

The x variable will be:

Food

Try it yourself Β»


Related Pages

HTML Reference: HTML <input> value Attribute


Image 14: Input Search Object Reference Input Search Object

← Prop Search SizeProp Search Required β†’