In jQuery, val and atrr (value) are different for browsers. If val () is assigned with a default value, when this value is modified, google cannot obtain the latest value. However, when ie can be used as a project, the data I pass from the background is assigned a value to a text box. In the google browser,
No modification was found during the modification, and the reason was finally checked. It turns ou
The story takes place in the background, the original module has been quoted all over theThe following is the general process after the successful uploading of picturesParentobj.siblings (". Upload-name"). Val (data.name);p arentobj.siblings (". Upload-path"). Val ( Data.path);p arentobj.siblings (". Upload-size"). Val (data.size);Assigning an IMG by extending $.
What
Val ([Val|fn|arr])Gets the current value of the matching element.
Get the value of a text box
Enter your name:type= "text">In the browser input box, type:$ (document). Ready (function () { $ ("input"). blur (function () { var a = $ ("input"). Val (); Console.log (a); The console prints the value of the input Box })
Valfunction(value) {varhooks, ret, isfunction, Elem= This[0]; if(!arguments.length) {//No Parameters if(Elem) {//first element //Consider the case where the element is checkbox,radio,option or select, when there is a Val hookHooks = jquery.valhooks[Elem.type] | |jquery.valhooks[elem.nodeName.toLowerCase ()]; //If the hook is present and has a get and the value obtained is not undefined, the value is returned if
1. Access to ContentThree simple and practical jQuery methods for DOM manipulation:
Text ()-Sets or returns the text content of the selected element
HTML ()-Sets or returns the contents of the selected element (including HTML tags)
Val ()-Sets or returns the value of a form field
PID= "Test">This is someb>Boldb>text in a paragraph.P>P>Name:inputtype= "text"ID= "Test2"value= "Mickey Mouse">P>$ ("#test"). Text ()------This was some
1.HTMLHTML (): Gets the HTML content of the first matching element. This function cannot be used with XML documents. But can be used in XHTML documentsHTML (val): Sets the HTML content of each matching element. This function cannot be used with XML documents. But it can be used in XHTML documents.2.TEXTText (): Gets the contents of all matching elements.The result is text that is combined with the text content contained by all matching elements. This
Differences between jQuery's val and atrr ("value") Assignment
When I was working on a project, the data I passed from the background assigned a value to a text box. In the google browser,
No modification was found during the modification, and the reason was finally checked. It turns out that val and atrr ("value" in jQuery are different from those in browsers,
The summary is as follows:
In jquery,
$ (this). attr (key); Gets the value of the node property name, equivalent to the getattribute (key) method$ (this). attr (Key,Value); Sets the value of the Node property, equivalent to the setattribute (Key,value) methodEg:class= "widget" diywidgetid= "${template.diywidgetid}" >VarDiywidgetid = $ (' #w_1 '). attr (' Diywidgetid '); Gets the value of the node property$ (this). Val (); Gets the value of an element node, which is equivalent to $ (this).
In php, while (list ($ key, $ val) = each ($ result) is used to read the $ result array value and obtain the array content cyclically and assign the value to $ key, $ val.
Example
The Code is as follows:
Copy code
Echo "all methods in the CAR class are named :";Echo "$ Result = get_class_methods ("CAR"); // obtain the method name get_class_methods () in the class CAR ()While (l
1:attr () Sets or returns the property valuealert ("Image width" + $ ("img"). attr ("width"));returns the attribute value of an element $ ("img").attr("width","180"); Set the attribute value of an element$ ("img"). attr ({width: "", "Height:"}); setting multiple Property values $ ("P"). Removeattr ("style"); Remove the style Property of the P tag > This is a paragraph. 2:html ():Sets or returns the HTML value of an element$ ("P"). html("Hello Set the contents of the P elementAlert ($ (
There are 3 main ways to get object content in jquery, namely HTML (), text (), Val ().Obj.html (): Gets all the HTML content of the object package, which is equivalent to innerHTML.Obj.text (): Gets all the text content in the object, without the HTML tag. Generally used for Div, p, span, etc. without the value attribute of the element, equivalent to innertext.Obj.val (): Gets the value of the object. Gets the value of the first element of a Selectio
When doing the project, I passed the data from the background to a text box to assign value, through the Google Browser,When the changes are found without modification, the final check for the following reason, the original is jquery in Val and ATRR ("value", the difference between the browser,Therefore, the summary is as follows:The use of Val () and ATRR (' value ') in jquery, assuming that there is a def
Text () gets the content of all matching elements. The result is a combination of text content contained by all matching elements. This method is effective for both HTML and XML documents. Get the text contents of all matched elements. The result is a string that contains the combined text contents of all matched elements. This method works on both HTML and XML documents. Return Value
StringExample
HTML code:JQuery code:$ ("P"). text ();
Result:Test Paragraph. paraparagraph plain text (
The following is a detailed analysis of the use of the macro #val in C + + under Unicode, the need for friends can refer to the following
#define CHECK (condition) cout
The above macro, when you CHECK (MyFunc ()); , suppose MyFunc returns false and outputs: Check Failed:myfunc ()
In a macro, #condition converts a parameter to a string, which makes it easy to print out the function name when the log is printed, and so on
This may all know, too small
The example in this article tells you that JQuery uses the Val method to read and write value values. Share to everyone for your reference. Specifically as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21-22
I hope this article will help you with your jquery programming.
which returns True if coordinates refer to same point in the plane (i.e., with the same x and Y Coordin ATE).
Define __repr__ , a special method that returns a string the looks like a valid Python expression that could being used to recre Ate an object with the same value. In other words, given the definition of from part eval(repr(c)) == c __eq__ 1.
NBSP; class Coordinate(object): def __init__(self,x,y): self.x = x self.y = y def getX(self): # Gette
Gets the text of the Select selected item: var item = $ ("select[@name =items] option[@selected]"). Text ();
Gets the text of the Select selected item: var item = $ ("Select[name=items] option[selected]"). Text (); or $ ("Select[name=items]"). Find ("option:selected"). Text ();
Value value of the dropdown box select: $ (' select '). val ();
Dropdown box Select the selected text value: $ ("select"). Find ("option:selected"). Text ();
Example
Let's take a look at the following example:Copy codeThe Code is as follows: Code:Copy codeThe Code is as follows:$ ("# Address"). focus (function () {// address box to get the mouse focusVar txt_value = $ (this). val (); // obtain the value of the current text box.If (txt_value = this. defaultValue ){$ (This). val (""); // if the conditions are met, the text box content is cleared.}}); Note: this. defaultVa
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.