how to add effect 'hide (“slow”)' to div inside a PHP while

后端 未结 1 943
旧巷少年郎
旧巷少年郎 2021-01-28 02:43

I have a form that is repeated several times within a div called \"formscontainer\" in PHP while, I want to make a form submit with their respective div disappears the effect hi

相关标签:
1条回答
  • 2021-01-28 03:34
    $(function () {
        $("form").each(function () {
            var par_div = $(this).closest('div'); //finding the closest div
            $(this).validate({
                submitHandler: function (formbeingsubmitted) {
                    $.post('process.php', $(formbeingsubmitted).serialize(), function (data) {
                        $('#results').html(data);
                        $(formbeingsubmitted).hide("slow");
                        par_div.hide('slow'); //hide the div
                    });
                }
            });
        });
    });
    

    you can also use

    $(this).parents('div'); instead of $(this).closest('div');

    but this $(this).closest('div'); is faster

    0 讨论(0)
提交回复
热议问题