JQuery 自动幻灯片
JQuery automatic slideshow
我正在尝试在我的网页上使用 JQuery 实现一个简单的自动幻灯片放映。
我遵循了本教程:https://www.youtube.com/watch?v=r5iPoJZjXnU。但是,我的 fadeOut() 和 fadeIn() 函数似乎运行不正常。代码有效,但图像之间的转换太快且不平滑。
这是我所做的:
在我的头部标签中添加了这些行以上传 jquery 和 jquery UI 图书馆:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
然后,在我的 body 标签的末尾,我简单地添加了:
<script type="text/javascript">
function galerie(){
var active = $("#slideshow .active");
var next = (active.next().length > 0) ? active.next() : $("#slideshow img:first");
active.fadeOut(function(){
active.removeClass("active");
});
next.fadeIn("slow").addClass("active");
}
</script>
每当我点击我的 h1 标签时调用这个函数:
<h1 onClick="galerie()">Pure</h1>
你有什么建议吗?
问题已解决,是我的html结构不对
我正在尝试在我的网页上使用 JQuery 实现一个简单的自动幻灯片放映。 我遵循了本教程:https://www.youtube.com/watch?v=r5iPoJZjXnU。但是,我的 fadeOut() 和 fadeIn() 函数似乎运行不正常。代码有效,但图像之间的转换太快且不平滑。
这是我所做的:
在我的头部标签中添加了这些行以上传 jquery 和 jquery UI 图书馆:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
然后,在我的 body 标签的末尾,我简单地添加了:
<script type="text/javascript">
function galerie(){
var active = $("#slideshow .active");
var next = (active.next().length > 0) ? active.next() : $("#slideshow img:first");
active.fadeOut(function(){
active.removeClass("active");
});
next.fadeIn("slow").addClass("active");
}
</script>
每当我点击我的 h1 标签时调用这个函数:
<h1 onClick="galerie()">Pure</h1>
你有什么建议吗?
问题已解决,是我的html结构不对