jQuery to serialize only elements within a div

后端 未结 8 1749
猫巷女王i
猫巷女王i 2020-11-28 20:52

I would like to get the same effect as jQuery.serialize() but I would like to return only the child elments of a given div.

Sample

8条回答
  •  攒了一身酷
    2020-11-28 21:18

    No problem. Just use the following. This will behave exactly like serializing a form but using a div's content instead.

    $('#divId :input').serialize();
    

    Check https://jsbin.com/xabureladi/1 for a demonstration (https://jsbin.com/xabureladi/1/edit for the code)

提交回复
热议问题