jel04h
2/12/2017 - 4:42 AM

Getting and Setting HTML Form Values // From https://www.safaribooksonline.com/library/view/jquery-pocket-reference/9781449398958/ch02s04.ht

// Get value from the surname text field
$("#surname").val() 
// Get single value from <select> 
$("#usstate").val()              
// Get array of values from <select multiple>
$("select#extras").val()         
// Get val of checked radio button
$("input:radio[name=ship]:checked").val()  
// 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: