我在使用 jQuery 时遇到问题
如果某些字段具有特定值,我想排除它们被序列化。就我而言,值(value)就是全部
我正在使用
jQuery("#charter-form").find("select,input").serialize()
结果是
lease=rent&type=all&lengthfrom=10&lengthto=60&yacht_name=all&from=all&to=all&number_of_guests=all
我希望我的结果是
lease=rent&lengthfrom=10&lengthto=60"
我尝试过使用 [value!='all']
、.not
、contains
等,但我没有运气
感谢您的宝贵时间
最佳答案
您可以过滤掉空值
jQuery("#charter-form").find("select,input").filter(function(){
return !(this.value === '');
}).serialize()
关于jquery - 从查找、序列化 Jquery 中排除具有特定值的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23300526/