Mr A Mr A - 6 months ago 22
Javascript Question

Using Jquery to hide/unhide the textbox if button is clicked

I have input button , what I want is if a user clicks on the button then textbox should appear.

Below is the code which is not working :

<input type="submit" value="Add Second Driver" id="driver" />
<input type="text" id="text" />

$("#driver").click(function() {

$('#text').show();

}
});


Also the textbox should not be visible initially

Answer

try this:

$(document).ready(function(){
    $("#driver").click(function(){
       $("#text").slideToggle("slow");
  });
});
Comments