Getting values in js can be used or used, so what's the difference?
Originally, I thought that adding all was to take all xx in the form (if there were multiple elements with the same name), and the returned array was an array. Later, I searched online and found that this was not the meaning.
All represents all elements in form, which means that you can access any element contained in the <form></form> tag, including div, table, etc., while you can only access form elements, such as input, select, etc.
The tests are as follows:
<form>
<div id=div1><input name=text1 id=text1></div>
<input name=text2 id=text2>
</form>
Only text1 and text2 (common for form elements, name and id), but text1, text2 and div1 can be accessed.
Common to form elements, name and id, for example above, form.text1 and .text1 are equivalent.
For non-form elements, they can only be accessed through (xx is id) form, or they can be omitted, that is, xx can be used directly.
Note: When accessing form elements, if there are multiple xx, the returned array will be
For non-form elements, if there are multiple elements with the same id, it represents the first element and the others will be ignored.
Originally, I thought that adding all was to take all xx in the form (if there were multiple elements with the same name), and the returned array was an array. Later, I searched online and found that this was not the meaning.
All represents all elements in form, which means that you can access any element contained in the <form></form> tag, including div, table, etc., while you can only access form elements, such as input, select, etc.
The tests are as follows:
Copy the codeThe code is as follows:
<form>
<div id=div1><input name=text1 id=text1></div>
<input name=text2 id=text2>
</form>
Only text1 and text2 (common for form elements, name and id), but text1, text2 and div1 can be accessed.
Common to form elements, name and id, for example above, form.text1 and .text1 are equivalent.
For non-form elements, they can only be accessed through (xx is id) form, or they can be omitted, that is, xx can be used directly.
Note: When accessing form elements, if there are multiple xx, the returned array will be
For non-form elements, if there are multiple elements with the same id, it represents the first element and the others will be ignored.