使用管道在可选择的收件人上显示隐藏DIV与联系表格7

时间:2014-02-08 05:07:05

标签: jquery wordpress contact-form-7

从此链接借用代码: http://wordpress.org/support/topic/plugin-contact-form-7-this-is-how-to-showhide-fields-with-jquery?replies=8

我创建了以下内容,但由于该值具有管道符,因此无效。当我移除管道时,它正常运行。我尝试逃避但是没有用。有什么想法吗?

我在Contact Form 7插件中的HTML代码

<p>Your Name (required)<br />
[text* your-name] </p>

<p>Your Email (required)<br />
[email* your-email] </p>

<label for="recipient">Choose your interest</label>
[select* recipient id:recipient include_blank 
 "events|events@example.com"
 "custom orders|customorders@example.com"]

 <div class="hide" id="hide1">
 <label for="event-type">Type of Event</label>[text event-type /50 id:event-type]
 </div>

 <p>Your Message<br />
 [textarea your-message] </p>

 <p>[submit "Send"]</p>

我的jQuery脚本:

$(document).ready(function() {

    //Hide the field initially
    $("#hide1").hide();

    //Show the text field only when the third option is chosen - this doesn't
    $('#recipient').change(function() {
            if ($("#recipient").val() == "events|events@example.com") {
                    $("#hide1").show();
            }
            else {
                    $("#hide1").hide();
            }
    });
});

0 个答案:

没有答案