jquery 获取表单数据
博客专区 > ossea 的博客 > 博客详情
jquery 获取表单数据
ossea 发表于1年前
jquery 获取表单数据
  • 发表于 1年前
  • 阅读 3
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

摘要: For a form element's value to be included in the serialized string, the element must have a nameattribute

The .serialize() method creates a text string in standard URL-encoded notation. It can act on a jQuery object that has selected individual form controls, such as <input><textarea>, and <select>$( "input, textarea, select" ).serialize();

It is typically easier, however, to select the <form> itself for serialization:

 

1

2

3

4

 

$( "form" ).on( "submit", function( event ) {

event.preventDefault();

console.log( $( this ).serialize() );

});

 

Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a nameattribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

 

共有 人打赏支持
粉丝 0
博文 18
码字总数 9673
×
ossea
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: