开发者

Need help combining jquery serialize with not or filter

开发者 https://www.devze.com 2023-02-19 16:37 出处:网络
I\'m trying to serialize a form and exclude certain elements. but nothing is working.here are some examples.

I'm trying to serialize a form and exclude certain elements. but nothing is working. here are some examples.

$.post("process.php", $("#featured-form").filter("select").serialize(), function(res) {
$.post("process.php", $("#featured-form").filter(".exclude").serialize(), function(res) {

do开发者_Python百科es anyone have any ideas??


First, filter() filters out the elements that don't match the specified selector. Since you seem to want the opposite behavior, you probably should use not() instead.

Then, you have to select the form elements in order to filter them, not the form itself. The following should do what you want:

$("#featured-form :input").not("select, .exclude").serialize();
0

精彩评论

暂无评论...
验证码 换一张
取 消