当我在控制台中运行$('#slides')。superslides()时,我的函数可以正常运行,但是当我在单独的JS文件中运行它时,它什么也不显示。
$(document).ready(function() {
$('#slides').superslides();
});
在脚本中正确引用了文件
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Brandon Bracho</title>
<link rel="stylesheet" href="CSS/superslides.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div id="slides">
<div class="slides-container">
<img src="https://via.placeholder.com/150" alt="">
<img src="https://via.placeholder.com/150" alt="">
</div>
</div>
<script src="Javascript/jquery.superslides.min.js"</script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<script src="Javascript/script.js"</script>
</body>
</html>
答案 0 :(得分:1)
它不起作用,您在脚本上有错字
<script src="Javascript/jquery.superslides.min.js"</script>
您没有关闭开始标签,请关闭它:
<script src="Javascript/jquery.superslides.min.js"></script>
以及您对脚本Javascript/script.js
的引用可能无效,因为这是绝对路径,请在浏览器控制台上检查它(检查是否已加载)