How can I get form data with JavaScript/jQuery?

前端 未结 28 2327
不知归路
不知归路 2020-11-22 12:39

Is there a simple, one-line way to get the data of a form as it would be if it was to be submitted in the classic HTML-only way?

For example:



        
28条回答
  •  无人共我
    2020-11-22 13:26

    I use this:

    jQuery Plugin

    (function($){
      $.fn.getFormData = function(){
        var data = {};
        var dataArray = $(this).serializeArray();
        for(var i=0;i

    HTML Form

    Get the Data

    var myData = $("#myForm").getFormData();
    

提交回复
热议问题