Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple jQuery - hide text box

Tags:

jquery

I am new jQuery, playing around with it. I would like text box when I click button but it doesn't work in that way.

<input type=text id=txt></input>
<input type=button id=btn value="Click Me"></input>

$document.ready(function() {
    $("input#btn").click(function() {
        $("input#txt").hide();
    });
});
like image 628
dotnetrocks Avatar asked Dec 19 '11 17:12

dotnetrocks


2 Answers

  $(document).ready(function(){      
    $("input#btn").click(function(){
      $("input#txt").hide();
    });
});

missed the () around document you can use the short cut also like

$(function(){

//your code here

});
like image 104
Rafay Avatar answered Oct 05 '22 23:10

Rafay


There is no such thing as $document.ready(

Try doing $(document).ready(

like image 20
Naftali Avatar answered Oct 05 '22 23:10

Naftali