Simple jQuery - hide text box

I am new jQuery, play with it. I would like a text box when I click the button, but this does not work.

<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();
    });
});
+5
source share
3 answers
  $(document).ready(function(){      
    $("input#btn").click(function(){
      $("input#txt").hide();
    });
});

skipped ()around document, you can use a short tenderloin, just like

$(function(){

//your code here

});
+5
source

There is no such thing as $document.ready(

Try to do $(document).ready(

+2
source

First of all, you should put "around" your html elements. After that, you can fix it as follows:

<input type="text" id="txt" />
<input type="button" id="btn" value="Click Me" onclick="$('#txt').hide()"/>
0
source

All Articles