我一直在使用javascript/jquery代码
下面是来自jsfiddle.net的代码我一直在使用javascript/jquery代码,javascript,jquery,html,css,Javascript,Jquery,Html,Css,下面是来自jsfiddle.net的代码 $(".scroll").click(function(event){ event.preventDefault(); //calculate destination place var dest=0; if($(this.hash).offset().top > $(document).height()-$(window).height()){ dest=$(document).he
$(".scroll").click(function(event){
event.preventDefault();
//calculate destination place
var dest=0;
if($(this.hash).offset().top > $(document).height()-$(window).height()){
dest=$(document).height()-$(window).height();
}else{
dest=$(this.hash).offset().top;
}
//go to destination
$('html,body').animate({scrollTop:dest}, 1000,'swing');
});
问题是,在JSFIDLE上,代码运行良好,没有任何问题。但是,当我尝试将它插入文本编辑器并运行它时,开发人员工具给出了一个警告,指出“top”未定义——但它在JSFIDLE中工作得非常好
有人知道为什么吗
::编辑::下面是列表中的内容
<head>
<script src="ajax.googleapis.com/ajax/libs/jquery-1.11.0.js"></script>
<script src="bootstrap.min.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">
<script type="text/javascript" src="app.js"></script>
<title>M Y | Portfolio</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap.min.css" rel="stylesheet">
<link href="carousel.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="jumbotron.css" rel="stylesheet">
</head>
M Y |投资组合
尝试单击抛出“top”未定义的链接“错误,检查它并检查其href属性是否已定义且不为空。您是否检查了代码中的每个变量是否都具有预期值?如果没有-为什么你没有?我认为你的代码很好,你添加了正确版本的jquery吗?是的,它已经被直接复制和粘贴。对我来说,没有任何警告,请尝试添加这个jquery-@PrabhatJain仍然得到错误:/