Smythu Smythu - 5 months ago 30
jQuery Question

jQuery 3 - Show and Hide

I have 3

div
's.


  1. Has a next button

  2. Has a back and a next button

  3. Has a back and submit button



jQuery

$('.next').click(function() {
//hide parent and show next
$(this).parent().hide().next().show();
});

$('.back').click(function() {
//hide parent and show previous
$(this).parent().hide().prev().show();
});


The 2nd page just appears for a few milliseconds and then goes back to the first one.. is it deprecated?

Answer

You could be submitting the page try preventing the event.

$('.next').click(function(e){
  e.preventDefault();
  $(this).parent().hide().next().show();
  //hide parent and show next 
});

  //your othe codes