gpt4 book ai didi

javascript - 如何在代码中包含 lightbox 和 easyPaginate Javascript 库? (这可能吗?)

转载 作者:行者123 更新时间:2023-11-28 03:20:01 26 4
gpt4 key购买 nike

我想将这两个 JS 库包含在我的代码中并让它们同时运行。

http://st3ph.github.io/jquery.easyPaginate/ https://lokeshdhakar.com/projects/lightbox2/

两个网站都提供有关如何使用库的信息。

我尝试设置这两个库,但一次只能运行一个。

这是我在下面的 index.php 页面底部包含的代码(index.php 是我想要使用这两个库的唯一页面)-

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="lightbox.js"></script>
<script src="jquery.easyPaginate.js"></script>
<script>
$('#easyPaginate').easyPaginate({
paginateElement: 'img',
elementsPerPage: 8,
effect: 'climb'
});
</script>

使用此代码,只有灯箱库可以工作。如果我将灯箱脚本移动到最底部,那么只有 easyPaginate 库可以工作。

如何让两个库同时工作?这可能吗?

我的代码 - 请阅读下面的“从这里读取”评论。 https://pastebin.com/m0jA9QYp

我已经在头部调用了 jquery 脚本。

最佳答案

是的,这是可能的 - 在一个文件中包含一个或多个库。你可以这样做:

在 html 文件中:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>

<script src="lightbox.js"></script>
<script src="jquery.easyPaginate.js"></script>

</body>
</html>

好的,但我仍然在页面上看到这个:

https://pastebin.com/m0jA9QYp :

  <script src="lightbox.js"></script>
<script src="jquery.easyPaginate.js"></script>
<script src="jquery.easyPaginate.js"></script>
<script>
$('#easyPaginate').easyPaginate({
paginateElement: 'img',
elementsPerPage: 8,
effect: 'climb'
});
</script>

所以如果你尝试这个:

</center> 
<script>
$('#easyPaginate').easyPaginate({
paginateElement: 'img',
elementsPerPage: 8,
effect: 'climb'
});
</script>
<script src="lightbox.js"></script>
<script src="jquery.easyPaginate.js"></script>

</body>

关于javascript - 如何在代码中包含 lightbox 和 easyPaginate Javascript 库? (这可能吗?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59248362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com