这是我的问题。我有你在下面看到的代码。为什么它在这里不起作用:http://jsfiddle.net/e6kaV/33/?
有是证明我的错误:
{
“消息”: “未捕获的ReferenceError:$没有定义”,
“文件名”: “http://stacksnippets.net/js”,
“LINENO”:54,
“colno”:13
}
每个帮助的赞赏,因为我不知道JS或jQuery如何工作。在使用它之前Javascript元素崩溃不起作用
.pane-launcher{
position:absolute;
top: 0;
width:80px;
height:80px;
display:block;
}
#rules {
left:0px;
}
#scenarios {
left:90px;
}
.pane{
position:absolute;
left: 0;
height:50px;
display:none;
opacity:1;
}
#rules-pane {
top:80px;
width:170px;
background-color:yellow;
}
#scenarios-pane {
top:80px;
width:170px;
background-color:blue;
}
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TEST</title>
<link rel="stylesheet" href="css.css">
</head>
<body>
<div id="rules" class="pane-launcher"><img src="http://placehold.it/80x80"></div>
<div id="rules-pane" class="pane">Model1</div>
<div id="scenarios" class="pane-launcher"><img src="http://placehold.it/80x80"></div>
<div id="scenarios-pane" class="pane">Model2<br><img src="http://placehold.it/170x20"></div>
<script>
$(".pane-launcher").click(function() {
\t // Set the effect type
var effect = 'slide';
// Set the options for the effect type chosen
var options = { direction: 'up' };
// Set the duration (default: 400 milliseconds)
var duration = 700;
$('.pane.active, #'+this.id+'-pane').toggle(effect, options, duration).toggleClass('active');
});</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>
你在哪里把Jquery的?你的jQuery没有被加载,因此在被调用时$是未定义的。 将jquery引用链接放在body关闭标记之前。 –
@damianocelent是不是:你的意思是?我认为这是jQuery,我已经在那里。 –
是的,那你在你的html放置它的地方? 把它放在