jQuery to serialize only elements within a div

后端 未结 8 1751
猫巷女王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:20

    You can improve the speed of your code if you restrict the items jQuery will look at.

    Use the selector :input instead of * to achieve it.

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

    This will make your code faster because the list of items is shorter.

提交回复
热议问题