How do I access values created by serializeArray in JQuery?

前端 未结 8 639
眼角桃花
眼角桃花 2021-02-02 09:33

I have this HTML:

And I create an object array from it lik

8条回答
  •  不思量自难忘°
    2021-02-02 10:00

    Similar to what Nick posted, but a little cleaner

    var dataArray = $("#myform").serializeArray(),
        dataObj = {};
    
    $(dataArray).each(function(i, field){
      dataObj[field.name] = field.value;
    });
    

    Then access the same way

    alert(dataObj['title']);
    

提交回复
热议问题