Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
jQuery.hide()在表单提交后不起作用_Jquery_Html_Css_Dom - Fatal编程技术网

jQuery.hide()在表单提交后不起作用

jQuery.hide()在表单提交后不起作用,jquery,html,css,dom,Jquery,Html,Css,Dom,我试图让一个表单工作,如果启用JS,我想隐藏可选字段。我有以下几行 $(document).ready(function(){ $('#anfrageFormularOptionalContainer').hide(); }); 当我第一次登上这一页时,一切都很顺利。可选容器设置为“显示:无;”。但是当我现在提交表单时,可选的容器被显示,但是它的css被设置为“display:none;”。那么,为什么它仍然显示?我真的不知道为什么会发生这种奇怪的事情。好吧,对

我试图让一个表单工作,如果启用JS,我想隐藏可选字段。我有以下几行

    $(document).ready(function(){
        $('#anfrageFormularOptionalContainer').hide();
    });

当我第一次登上这一页时,一切都很顺利。可选容器设置为“显示:无;”。但是当我现在提交表单时,可选的容器被显示,但是它的css被设置为“display:none;”。那么,为什么它仍然显示?我真的不知道为什么会发生这种奇怪的事情。

好吧,对每个人来说,这是一个错误,是由我使用modx的方式造成的。所以我必须用其他的方法

这不是JS的错误,所以答案不属于这里


无论如何,谢谢大家!!!你对我很有耐心,非常感谢

ID太短,只有超过100个字符长的ID才会在表单提交后隐藏。不要将Jquery hide()与CSS显示混合使用。@bobthyasian-为什么不?请添加其他相关代码好吗?从表单提交开始,是否使用ajax发送表单?还是页面刷新了?@adeneo-wut?您是指具有id属性的dom元素吗?我想我误解你了。。。id属性的长度根本不重要,也不应该重要