繁体   English   中英

如果 div 具有特定样式,jquery/js 隐藏提交按钮

[英]jquery/js hide submit button if div has specific style

如果能提供帮助,我将不胜感激。 当特定错误消息可见时,我尝试隐藏提交按钮,当消息消失时显示提交按钮。 我需要使用 data-id 属性。

看起来我的代码在我使用 google chrome 控制台时有效,但只能一次使用。 当我将其包含在网站中时,它根本不起作用。

抱歉,如果我没有完美地描述这一点。 这是我的第一篇文章,所以我希望你能理解。

if($('div[data-id="opce_error"]').css('display') === 'none') {
     $(".wpcf7-submit").show();
  }
  if($('div[data-id="opce_error"]').css('display') === 'block') {
     $(".wpcf7-submit").hide();
  }
<div data-id="opce_error" data-orig_data_id="opce_error" data-class="wpcf7cf_group" class="" style="display: block;">
<label class="assets-error">Submit button is hidden</label>
</div>

你在 jQuery 的 onReady function 中使用这个? html 还在渲染? 也许您可以使用 pastebin 或类似工具给我们一个示例演示吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM