简单的jQuery - 隐藏文本框

dot*_*cks 5 jquery

我是新的jQuery,玩弄它.当我点击按钮时我想要文本框但是它不能以这种方式工作.

<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();
    });
});
Run Code Online (Sandbox Code Playgroud)

Raf*_*fay 7

  $(document).ready(function(){      
    $("input#btn").click(function(){
      $("input#txt").hide();
    });
});
Run Code Online (Sandbox Code Playgroud)

错过了()周围document你可以使用捷径也喜欢

$(function(){

//your code here

});
Run Code Online (Sandbox Code Playgroud)