1
4

1 回答 1

2

Here's the corrected jsFiddle for the same: http://jsfiddle.net/9zsdN/1/

$("#open_close_doors").click(function(){ $("#leftdoor_inner").animate({"left": "-=50px"}, "slow");});​

It should be:

$(".open_close_doors").click(function(){
  $("#leftdoor_inner").animate({"left": "-=50px"}, "slow");
});​

The difference lies in the way you access an element. As you can see, when you access an element by class, you use " .classsname" instead of "#classname" as you have done.

"#name" is used for accessing elements by their id.

于 2012-10-25T05:37:30.710 回答