具有标题属性的空输入字段的 JQuery 序列化函数
我有以下表单输入字段:
<input type="text" value="" title="Enter item description" name="description">
当我在包含表单上调用 JQuery 的序列化函数时,它会给出以下内容:
description=Enter+item+description
有谁知道为什么 serialize() 将标题作为描述字段的值?我该如何解决这个问题?我希望结果是:
description= (i.e. no value)
I have the following form input field:
<input type="text" value="" title="Enter item description" name="description">
When I call JQuery's serialize function on the containing form, it gives me the following:
description=Enter+item+description
Does anyone know why serialize() takes the title as a value for the description field? How can I get around this? I want the result to be:
description= (i.e. no value)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是
serialize()
的行为。我认为您可能有另一个插件或代码将标题标签的值加载到字段的值中。我知道有很多插件使用该值来创建幻影文本或在输入字段上进行掩码。当您使用serialize()
时,这可能会导致它被视为值。实际上我刚刚测试过它并且它按预期工作。请参阅此处:http://jsfiddle.net/XrVvM/Thats not the behavior of
serialize()
. I think you may have another plugin or code that is loading the value of the title tag into the value of the field. I know there are many plugins that use the value to create ghost text or to do a mask on the input field. That maybe causing it to be considered the value when you useserialize()
. I actually just tested it and it works as expected. See here: http://jsfiddle.net/XrVvM/