I'm trying to make a form with multiple windows, but I do not understand what's going wrong.
What I want to do is that by clicking the buttons it hides and shows the next form.
UPDATE
I followed @afonso's suggestion, but it still is not working, I even updated my codepen, it does not work there either.
$( window ).load(function() {
$('form button').on('click', trataForm);
function trataForm(event) {
event.preventDefault();
var $bloco = $(event.currentTarget).parents('div');
$bloco.removeClass('active');
if($(this).hasClass('next')){
if ($bloco.is(':last-child'))
$(event.currentTarget).parents('form').submit(); //<-aqui
else
$bloco.next().addClass('active');
}else{
if (!$bloco.is(':first-child'))
$bloco.prev().addClass('active');
}
}
});
I'm on WordPress. I made a plugin that adds css
and js
. It forces you to make calls within a function, or $( window ).load
, and for some reason it always falls into the first condition (where I put the comment '