为什么这个简单的jQuery不起作用?

n0p*_*0pe 1 html javascript css jquery

jQuery的:

<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
$(document).ready({
   $(".title").click(function(){
      var descID = $(this).attr("id");
      var newID = "#"+descID+"d";
      $(newID).slideToggle('slow');
   });
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<span id="3" class="title">title</span>
<span id="3d" class="description">description</span>
Run Code Online (Sandbox Code Playgroud)

CSS:

.description {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

不是jQuery/javascript专家.我错过了什么?我正试图description在点击正确的时候进行适当的滑动切换title.现在我没有看到任何事情发生.

eba*_*axt 5

您之后缺少一个函数:$(document).ready(

应该:

<html>
<head>
...
    <style type="text/css">
        .description {
            display: none;
        }
    </style>
</head>
<body>
<span id="3" class="title">title</span>
<span id="3d" class="description">description</span>
<script type="text/javascript">
    $(document).ready(function() {
        $(".title").click(function () {
            var descID = $(this).attr("id");
            var newID = "#" + descID + "d";
            $(newID).slideToggle('slow');
        });
    });
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)