WordPress / Gravity Forms – Show/hide a div based on value of a number field

HUZZAH!πŸŽ‰πŸŽ‰πŸŽ‰ After some more testing I figured it out!

The problem wasn’t with my IF statement, it was that there was nothing registering the change to the field to trigger the IF statement. Also, I apparently didn’t need that extra variable in there… ANYWAY, this is what worked:

jQuery(function ($) {
    var total = $(':input[name=input_5]');
    total.change(function() {
    if (total.val() === "2")
        jQuery(".conditional-div").hide();
    else
        jQuery(".conditional-div").show();
    });
});

Leave a Comment