I'm trying to show a div one after the other when my "add_more" button is clicked. The first click works as I would like, but on the second click all of the divs show.
$(document).ready(function() {
$('#add_more').click(function() {
$('#add_more_fields').show(500);
});
});
$('#add_more').click(function() {
if($('#add_more_fields').is(':visible')) {
$('#add_more_fields2').show(500);
};
});
$('#add_more').click(function() {
if($('#add_more_fields2').is(':visible')) {
$('#add_more_fields3').show(500);
};
});
$('#add_more').click(function() {
if($('#add_more_fields3').is(':visible')) {
$('#add_more_fields4').show(500);
};
});
$('#add_more').click(function() {
if($('#add_more_fields4').is(':visible')) {
$('#add_more_fields5').show(500);
};
});
I see the problem as being that all of these are tied to one click function and triggering at the same time. How do I separate the events, so that each click adds the next div?