我试图让我的div隐藏,如果另一个div存在,并在网上查看示例后,我不知道我在做什么错误。任何帮助是极大的赞赏。谢谢!检查是否存在一个div类来隐藏另一个div
$('#required-field').toggle(!$('#gform_confirmation_message_1').length);
HTML:
<div id="gforms_confirmation_message" class="gform_confirmation_message_1">
<meta charset="UTF-8">
<div id="gform_confirmation_wrapper_1" class="gform_confirmation_wrapper ">
<div id="gform_confirmation_message_1" class="gform_confirmation_message_1 gform_confirmation_message">
Thank you for contacting us. We will make every effort to respond to you inquiries shortly.
</div>
</div>
</div>
<div id="required-field">* Required Fields</div>
我写了一个答案,但很难将您实际的代码没有更多的信息,比如你的HTML或JS提琴。 – Dan 2014-09-10 22:13:17
你可以证明这不工作,它看起来应该... – 2014-09-10 22:14:13
我看不出为什么我的代码和@Dan代码也不会工作。 – tjoenz 2014-09-10 22:21:48