问题描述
这从我跑到这里的错误流出,其中有一个名为elements的表单标签,如下所示:
code>表单元素的属性。我希望你明白了。This flows from the error I ran into here jQuery $(’form’).serialize() returns only one element of a form serialized where having a form tag named "elements", like so:
<form> <input name="elements"/> <input name="e2"/> </form>prevents you from accessing all the named elements of the form with jQuery's $('form').serialize() (i.e. you get "elements=" where you should get "elements=&e2=").
I'd like to have more general information about what proper "name" elements of form tags. I.e. what are the off-limits tags ("elements", "name", etc.), and what are the valid characters for a name. Are these things defined in a standard, or a reference manual, or is it trial and error?
Thoughts and input appreciated.
Thanks for reading.
解决方案Beside what Jonathan Sampson said you should not use names that are used for form objects properties. There is a list on Mozilla Developer Center, which if you'll look carefully contains an elements property important for you because form elements may be accessed as direct attributes of the form object. For example in your case:
form.elements; // collides with the built-in elements property form.e2;So be careful not to use names like method, or action which will also collide with the value of the method and action attributes of the form element. I hope you got the idea.
这篇关于jQuery中HTML表单标签的有效/无效名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!