【问题标题】:Remove all inputs that don't have the id's x or x删除所有没有 id 的 x 或 x 的输入
【发布时间】:2009-09-30 13:10:08
【问题描述】:

我的 asp.net 页面中有一个来自第三方的小部件。我不能使用嵌套表单,所以我暂时更改 asp.net 的方法和操作以使用小部件。

我有一个 js 方法,我的小部件方法调用中的元素

function changeActionAndMethodOnFormAndSubmit(newAction, newMethod, newName) {
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.Form1;
    }
    theForm.action = newAction;
    theForm.method = newMethod;
    theForm.name = newName;
    theForm.submit();
}

我想在提交表单之前删除页面上的所有输入元素,除了我需要的那些。我知道基于参数 newName 的元素的确切 ID,但现在,假设我试图删除所有 input.id 不为 x 或 y 的输入元素。

【问题讨论】:

    标签: jquery forms


    【解决方案1】:

    应该这样做:

    $('input:not(#x,#y)', theform).remove()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-31
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多