javascript - 删除数据 jQuery

标签 javascript jquery

如果我有一个为 AJAX 查询构建的表单,如下所示:

var formData = new FormData($('#myForm')[0]);

如果我想从 myForm 中删除输入元素,我可以这样做:

我尝试过 $('#myForm')[0].elementToRemove.remove();但我在控制台中收到错误消息,指出对象不支持该属性或方法。

所以我需要类似的东西:

$('#myForm')[0] // remove an input element here
// now build the formData with that element removed
var formData = new FormData($('#myForm')[0]);

这可能吗?

最佳答案

jQuery.remove()正确地,您应该将其用作:

$("your-selector").remove();

喜欢:

$("#myForm").remove("input[name='your_input_name']");

关于javascript - 删除数据 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27007244/

相关文章:

javascript - Jquery停止事件触发

jquery - 基于 jquery 中的 css 属性的条件更改(if/then)

PHP/JavaScript OnMouseOver 链接不工作

javascript - 传单.js : Linking Activities to Map Markers

javascript - VueJS 父元素与子元素的通信

javascript - 通过 jQuery 重新加载页面

javascript - HTML5 Canvas 变形

javascript - execCommand justifycenter

javascript - 尝试设置 href 时,element.setAttribute 不是函数

jquery - 根据选择值显示/隐藏 div