WordPress.org

Forums

Contact Form 7 - jQuery checkbox (2 posts)

  1. jellesn
    Member
    Posted 1 year 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 1 year 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.

Topic Closed

This topic has been closed to new replies.

About this Topic