我遵循了一个关于如何使用jQuery隐藏/显示Contact Form 7字段的教程(在Wordpress中):
https://wordpress.org/support/topic/plugin-contact-form-7-this-is-how-to-showhide-fields-with-jquery
我之前使用过它并且它创造了奇迹。但是,在新网站上,出于某种原因,它无法正常工作。有问题的页面在这里:
http://saintsfoundation.co.uk/application-form-for-charitable-support/
字段隐藏正常(正如您将看到的),但是在点击显示的字段时不显示!有谁可以帮我解决这个问题?
提前致谢!
以下是代码:
HTML
<p>You are an employee or official representative of a charity or community group (i.e. you are not a third party raising funds on their behalf (required):<br />
[select* criteria-question-1 label_first include_blank "Yes" "No"] </p>
<p>The fundraising will benefit people in the Southampton and/or Hampshire area (required):<br />
[select* criteria-question-2 label_first id:form include_blank "Yes" "No"] </p>
<div class="hide" id="hide1">
<p>Name of organisation (required):<br />
[text* org-name placeholder "Enter organisation name here"] </p>
</div>
的jQuery
$(document).ready(function() {
//Hide the field initially
$("#hide1").hide();
//Show the text field only when the third option is chosen - this doesn't
$('#form').change(function() {
if ($("#form").val() == "Yes") {
$("#hide1").show();
}
else {
$("#hide1").hide();
}
});
});