How do I access values created by serializeArray in JQuery?

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

I have this HTML:

And I create an object array from it lik

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 10:24

    With uderscore.js, this is how we can go about it:

    var serializedArray = $('form#spiderman-application').serializeArray();
    
    var serializedObject = _.object(
      _.pluck(serializedArray, 'name'), 
      _.pluck(serializedArray, 'value')
    )
    
    console.log(serializedObject);
    
    
    
    
    Application Form

    Good Luck...

提交回复
热议问题