0

我正在尝试使用 jqueryclick函数为我的按钮提供一些功能。但是当我运行代码时,该函数根本不会被调用。

我的代码是:

 <script type="text/javascript">
 $(function () {
     $("#min").click(function(e){
         $("#listFriends").css('display','none');
         $("#friendsO").show();
     });
 </script>

<button id="min">[-]</button>

请任何人告诉我我在这段代码中犯了什么错误......谢谢............

4

2 回答 2

3

您缺少});关闭文档就绪处理程序。

$(function() {
   $("#min").click(function(e){
      console.log('test');
      $("#listFriends").hide();
      $("#friendsO").show();
   });
}); // <----

如果动态生成元素,则应该从元素或document对象的静态父对象之一委托事件:

$(document).on('click', "#min", function(e){
      console.log('test');
      $("#listFriends").hide();
      $("#friendsO").show();
});
于 2013-02-23T21:06:13.303 回答
0

在 firefox 上安装 firebug 并启用调试,请参见此处

于 2013-02-23T21:12:24.317 回答