jQuery API | jQuery API 中英文对照版 |
serialize() |
serialize()
把Input元素的内容连接成为一个请求字符串 返回值:String 示例: Serialize a selection of input elements to a string HTML 代码: <input type='text' name='name' value='John'/> <input type='text' name='location' value='Boston'/> jQuery 代码: $("input[@type=text]").serialize(); serialize() Serializes a set of input elements into a string of data. This will serialize all given elements. A serialization designed to emulate the actual form submission of a browser is provided by the Form Plugin. The plugin's formSerialize method correctly handles multiple-selects and identically-named checkboxes as arrays, whereas the serialize method recognizes only a single value for these elements. Return value: String Serialize a selection of input elements to a string $("input[@type=text]").serialize();Before: <input type='text' name='name' value='John'/> <input type='text' name='location' value='Boston'/>Result: name=John&location=Boston |