我想在我的代码中包含这两个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库将起作用。
如何使两个库同时工作?那有可能吗?
是,可以-在文件中包含一个或多个库。您可以这样:
在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>