General method of value-taking
$ ("#id"). Val ();
$ ("#id"). attr ("value");
Where value is the Cifname attribute of the element's property name, such as <s:textfield id= "Cifname" key= "name=" Consbean.cifname "#request./>" Id,key,name. The value that is fetched is the character that corresponds to the double quotation mark after the attribute.
function Saveconsumervalidate () {
var cifno =$ ("#cifNo"). Val ();//jquery Get text Box value Method 1
var cardtype = $ ("#cardType" ). attr ("value"); jquery Get text Box value Method 2
var Cardno = document.getElementById ("Cardno"). Value;//dom Get Value method
Val (), Val (val) method Atttr (name), Atttr (Key,value) method, and Value property
When you use $ ("#id") to get the input element of the page, $ ("#id") is found. Value cannot be fetched
$ ("#intro") is a jquery selector The result is the first element of id= "Intro" instead of the HTML DOM getElementById () method document.getelement
Value is a property of the HTML DOM text object that sets or returns the value of the text field's Values property.
Val () is the way jquery Gets or sets the DOM attribute of an element.
Val () Method: Gets the current value of the first matching element
Value: $ ("#id"). Val (); |$ ("element Elements"). Val ();
or $ ("#id") [0].value;
HTML code:
<input type= "text" value= "some text"/>
jQuery Code:
$ ("input"). Val ();
Val (val) method: Sets the value of each matching element.
Assignment: $ ("#id"). Val ("new value");
or $ ("#id") [0].value = "New value";
HTML code:
<input type= "text"/>
jQuery Code:
$ ("input"). val ("Hello world!");
attr (name) method: Gets the property value of the first matching element. This method makes it easy to get the value of a property from the first matching element. Returns undefined if the element does not have a corresponding property.
Value: $ ("#id"). attr ("value");
HTML code:
jQuery Code:
$ ("img"). attr ("src");
Result:
test.jpg
attr (Key,value) method: Sets a property value for all matching elements.
Assignment: $ ("#id"). attr (Attribute,value);
Description:
Sets the SRC attribute for all images.
HTML Code:
jQuery code:
$ ("img"). attr ("src", "test.jpg");
Results:
[, ]
The above jquery get form form INPUT element value Simple example is small series share to everyone's content, hope to give you a reference, also hope that we support cloud habitat community.