2/12/2017 - 4:42 AM

Getting and Setting HTML Form Values // From

// Get value from the surname text field
// Get single value from <select> 
// Get array of values from <select multiple>
// Get val of checked radio button
// Set value of a text field
$("#email").val("Invalid email address")   
// Check any checkboxes with these names or values
$("input:checkbox").val(["opt1", "opt2"])  
// Reset all text fields to their default
$("input:text").val(function() { 
    return this.defaultValue;

// Getting and Setting HTML Form Values
// val() is a method for setting and querying the value attribute of HTML form elements, and also for querying and setting the selection state of checkboxes, radio buttons, and <select> elements: