2012-03-02 175 views

回答

1

你有你的样品中的额外});。这里修好了: http://jsfiddle.net/PUdSn/5/

的代码应该是:

$(".thumbnail").on('click', function(){ 
    $(this).animate({height:"500px"},1500); //adding the px makes it clearer 
});​ 
+2

疲劳会做它的事情,谢谢。 – metrampaz 2012-03-02 19:46:00

+0

@metrampaz确实,尤其是当它深夜:) – gideon 2012-03-03 06:13:23

1

没什么只是一个错字:你在你的演示有额外});

  $(".thumbnail").on('click', function(){ 
        $(this).animate({height:500},1500);  
      }); 

}); // remove those! 

demo

1

有缺少一个右支架和你错过$(document).ready (function() { ... }

$(document).ready(function() { 
    $(".thumbnail").on('click', function() { 
     $(this).animate({ 
      height: 500 
     }, 1500); 
    }); 
}); 

工作DEMO

+0

@KirkWoll你点击了,它没有动画?它适合我这里。 – 2012-03-02 19:34:42

+0

呃,当然点击! – 2012-03-02 19:36:45

0

正如其他人所说,你只有在一个错字,你有一个额外的});。这并没有改变任何东西,但是你可以去掉on,直接设置click()方法。

$(".thumbnail").click(function(){ 
    $(this).animate({height:"500px"},1500); 
});​ 

而且,以供将来参考,这是很容易使用某种Web开发人员工具包的捕获。在IE中它是内置的,你只需要打F12。在Chrome中内置,你只需要按Ctrl + Shift + I。而且,在Firefox中,我不相信它是内置的,但是您可以使用firebug和/或web dev作为扩展。希望这可以帮助未来的调试:)