【发布时间】:2014-07-17 07:06:52
【问题描述】:
此代码在 jsfiddle 上运行良好,但在浏览器中无法运行,有什么想法吗?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(function () {
$("#clickme").click(function () {
if ($("#slideout").hasClass("popped")) {
$("#slideout").animate({
left: '-280px'
}, {
queue: false,
duration: 500
}).removeClass("popped");
} else {
$("#slideout").animate({
left: "0px"
}, {
queue: false,
duration: 500
}).addClass("popped");
}
});
});
</script>
<style>
body {
overflow-x: hidden;
}
#slideout {
background: #666;
position: absolute;
width: 280px;
height: 80px;
top: 45%;
left: -280px;
padding-left: 20px;
}
#clickme {
position: absolute;
top: 0;
left: 280px;
height: 20px;
width: 20px;
background: #ff0000;
}
#slidecontent {
float: left;
}
</style>
<title></title>
</head>
<body>
<div id="slideout">
Yar, there be dragonns herre!
</div>
<div id="clickme"></div>
</body>
</html>
【问题讨论】:
-
我没有看到您的脚本中包含 jQuery?你忘了包含 jQuery 吗?
标签: javascript jquery html css animation