我有一个搜索表单,其中包含许多通过GET提交的文本输入和下拉菜单.我想通过在执行搜索时从查询字符串中删除空字段来获得更清晰的搜索URL.
var form = $("form");
var serializedFormStr = form.serialize();
// I'd like to remove inputs where value is '' or '.' here
window.location.href = '/search?' + serializedFormStr
Run Code Online (Sandbox Code Playgroud)
知道如何使用jQuery做到这一点?