Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery清除父页面中的所有文本框字段_Javascript_Jquery - Fatal编程技术网

Javascript 如何使用jquery清除父页面中的所有文本框字段

Javascript 如何使用jquery清除父页面中的所有文本框字段,javascript,jquery,Javascript,Jquery,是使用jquery或javascript清除父窗体中所有文本框值的任何方法。 现在我正在使用 var parentDoc1 = window.opener.document; parentDoc1.getElementById(id).value=""; 在所有输入字段中使用类 试试这个 $('input.className').val(''); 拨弄 或 这将使文档中的所有inputfield的值都为空 $('input[type="text"]').val(''); 如何清除所有文本

是使用jquery或javascript清除父窗体中所有文本框值的任何方法。 现在我正在使用

var parentDoc1 = window.opener.document;
parentDoc1.getElementById(id).value="";
在所有输入字段中使用类

试试这个

 $('input.className').val('');
拨弄

这将使文档中的所有inputfield的值都为空

$('input[type="text"]').val('');

如何清除所有文本框:

$('input[type="text"]').val('');

你也可以这样用

$('input:text').val('');

这将清除id为parent的parent中所有文本区域的值

这里有一个例子

重要的是,脚本只清除作为父级直接同级的文本区域,而不是嵌套的文本区域

如果要重置父对象的同级之间的文本区域的值,则应将子对象替换为“查找”

如果希望脚本使用文本输入,请使用:

$('#parent').children('input[type=text]').val('');


同样取决于您的需要。

是否要在其他选项卡/窗口中选择页面内容?或者您希望获取父页面内容,因为您的上下文是您在iframe中?如果是最后一个,不要使用

window.opener.document;
请使用以下命令

window.parent.document;

如果您仍然在使用jQuery,您可以只使用.reset而不是.val。

您还可以在父窗口上创建函数并从子窗口调用它。 在子窗口中调用父函数,如下所示

<script>
function ClearFromChild(ARGS)
{
    window.opener.clearinparent(ARGS);
}
</script>
现在,只需在父窗口中声明clearinparent函数,就完成了。 干杯,

要清除所有文本框,您可以使用以下命令:

$(parentDoc1).find('input[type=text]').val('');
如果某些文本框,例如带有mytextboxclass类、mytextboxid id等的文本框。。。不得清洁,然后您可以在选择器中使用:not来排除这些:

$(parentDoc1).find('input[type=text]:not(.mytextboxclass,#mytextboxid)').val('');

$parentDoc1.find'input[type=text]'.val?@Engineer…工作正常你知道如何转义一些文本框吗?你说的“转义”是什么意思?…排除?是的,我想排除一些文本框$'.classname'必须搜索整个dom!$'“input.classname”会更好
$(parentDoc1).find('input[type=text]').val('');
$(parentDoc1).find('input[type=text]:not(.mytextboxclass,#mytextboxid)').val('');