Documentation

Val

From jQuery JavaScript Library

Jump to: navigation, search

.val() function - DOM manipulation

This function gets the value set in a form field. If there is a value between quotes inside the brackets it changes the current value of the given field for that one.

Example

 alert($("#input_1").val());
 $("#input_2").val("My name");


Before

 
  <input id="input_1" value="Hello" />
  <input id="input_2" value="World" />
  


After:

 
  <input id="input_1" value="Hello" />// Browser alerts 'Hello'
  <input id="input_2" value="My name" />
  



Links



Thales Jacobi 23:06, 12 July 2008 (PDT)

Retrieved from "http://docs.jquery.com/Val"