I have this HTML:
<form action="" id="product_create" method="post">
<ul>
<li id="tab1" data-display="categories-picker"><a href="#">Seleccionar categoría</a></li>
<li id="tab2" data-display="product-create-step-2"><a href="#">Datos</a></li>
<li id="tab3" data-display="product-create-step-3" style="display: none"><a href="#">Variaciones</a></li>
<li id="tab4" data-display="product-create-step-4"><a href="#">Detalles del Producto</a></li>
<li id="tab5" data-display="product-create-step-5"><a href="#">Condiciones de Venta</a></li>
</ul>
<fieldset id="categories-picker">
....
</fieldset>
<fieldset id="product-create-step-2" style="display: none">
....
</fieldset>
<fieldset id="product-create-step-3" style="display: none">
....
</fieldset>
<fieldset id="product-create-step-4" style="display: none">
....
</fieldset>
<fieldset id="product-create-step-5" style="display: none">
....
</fieldset>
<button type="button" name="finish-wizard" id="finish-wizard" style="display:none">Finish</button>
</form>
<button type="button" name="previous" id="previous-step" disabled="disabled">« Previous</button>
<button type="button" name="next" id="next-step">Next »</button>
In order to toggle or hide previous/show next I need to get the ID of the previous/next fieldset element when I click on $(input[name="next"])
or $(input[name="previous"])
but I made this code:
var first = $('fieldset').eq(0).attr('id');
var step = 1;
$('#next-step').click(function() {
if (step >= 1) {
$("#previous-step").removeAttr("disabled");
}
var current = $('fieldset').eq(step).next('fieldset');
var previous = $('fieldset').eq(step).prev('fieldset');
current.show();
previous.hide();
step++;
});
$('#previous-step').click(function() {
var current = $('fieldset').eq(step).next('fieldset');
var previous = $('fieldset').eq(step).prev('fieldset');
current.hide();
previous.show();
step--;
});
But it's not working fine, can any give me a help?