WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7 - jQuery checkbox (2 posts)

  1. jellesn
    Member
    Posted 5 months ago #

    $(document).ready(function() {
    
            //Hide the field initially
            $("#hide3").hide(); 
    
            //Show the text field only when the third option is chosen - this doesn't
            $('#nieuwsbrief').change(function() {
                    if ($("#nieuwsbrief").val() == "Ja") {
                            $("#hide3").show();
                    }
                    else {
                            $("#hide3").hide();
                    }
            });
    
    });
    [checkbox* nieuwsbrief id:nieuwsbrief "Ja"]
    
    <div class="hide" id="hide3">
    [email email]
    </div>

    How to get this working? With select it works perfectly..

  2. bcworkz
    Member
    Posted 5 months ago #

    I think you need a different event trigger, such as 'click'. Unlike the select element, the 'change' event does not fire until the checkbox loses focus, which is not the expected behavior in this case.

Reply

You must log in to post.

About this Topic