I get the content of the corresponding node through HTML (), and I find a problem that the content value of the form component is the initial loaded value, not the user-modified value. For example, when a page loads a component <input type= "text" value= "111111"/>, the user changes the form to a value of 222222 and obtains the component through the parent node's HTML () method, which is expected to be <input type= "text "Value=" 222222 "/>, but the result is the initial appearance <input type=" text "value=" 111111 "/>.
After debugging, it is found that changing the value of the form by the user does not change the HTML value of the corresponding form node, but instead changes the value of the property cached in memory (for example, properties) and the browser displays the value of the property. Not the value of the Value property (if textarea is the. html () value). So this problem arises because we mistakenly assume that the value used by the browser display is stored at the beginning of the property used to display the value in the browser (if textarea is the value of. html ().
If you want to make the content obtained through HTML () consistent with the display, you can use a few of the following methods
Some examples of ways to change the value of HTML
$ (". Box_content input[type= ' text ']"). each (function (index, Element) {//input text label
$ (this). attr (' Value ', $ (this). Val ());
});
$ (". Box_content textarea"). each (function (index, Element) {//textarea label
$ (this). The HTML ($ (this). Val ());
});
Then execute $ (". Box_content"). html ();
Note: When the form form uses the Reset method, it is actually the value of the store where the browser display value is used (Input[text] is value,textarea. HTML ()) values are re-assigned to the property that holds the user's modified form value (that is, Val () The location of the value that the method obtains)
Gets the text content through HTML (), the form component displays a value that is inconsistent with the obtained value