udayakumarb udayakumarb - 7 months ago 26
Javascript Question

jquery button click not working second time on fieldset?

I have 11 FieldSet using and also have 11 buttons for skipping purpose,

Html

<button id="skip1">1</button>
<button id="skip2">2</button>
<button id="skip3">3</button>


Jquery

$("#skip1").click(function(){
alert("In1")
$("#field_1").show();
});
$("#skip2").click(function(){
alert("In2")
$("#field_2").show();
});

$("#skip3").click(function(){
alert("In3")
$("#field_3").show();
});


The First time they working fine another time didn't work, only throw the alert Otherwise If possible to skip fieldset? Please give me a suggestion.

Answer

show one fieldset and hide others using hide().Try this:

$("#skip1").click(function(){
       $("#field_1").show();
       $("#field_2").hide();
       $("#field_3").hide();
});
$("#skip2").click(function(){
      $("#field_2").show();
      $("#field_1").hide();
      $("#field_3").hide();
});
$("#skip3").click(function(){
      $("#field_3").show();
      $("#field_1").hide();
      $("#field_2").hide();
});