使用JQuery淡出JSON ajax列表
Fade in JSON ajax list with JQuery
我有以下滑块:
https://jsfiddle.net/lucasmosele/px9ar93y/1/
我的间隔代码如下:
var counter = 1;
var elements = json.slider.length;
// Set timer between quotes being visible
$("#quotes li:first-child").addClass("active");
int = setInterval(function(){
$("#quotes li:nth-child(" + counter + ")").removeClass("active");
$("#quotes li:nth-child(" + counter + ")").next().addClass("active");
if (counter === elements){
counter = 1;
} else {
counter++;
}
}, 3000);
我想有新的内容fadeIn,我已经试过了。fadeIn:
$("#quotes li:nth-child(" + counter + ")").next().addClass("active").fadeIn("slow");
但我得到了我不一定想要的行为。我还尝试在li和li.active之间创建css转换,但由于某种原因,除非.fadeIn设置为"slow",否则它们不会显示。
有更干净的方法吗?
您可以进行
$("#quotes li:nth-child(" + counter + ")").next().hide().addClass("active").fadeIn("slow");
在此处播放
我想这就是您想要的:
$("#quotes li:first-child").addClass("active");
int = setInterval(function(){
$("#quotes li:nth-child(" + counter + ")").fadeOut('slow', function() {
$("#quotes li:nth-child(" + counter + ")").next().fadeIn('slow');
});
if (counter === elements){
counter = 1;
} else {
counter++;
}
}, 3000);
这是jsfiddle:https://jsfiddle.net/px9ar93y/6/
相关文章:
- 无法在mvc视图中使用ajax调用获取操作返回的模型对象列表
- Ajax调用ERror Cross Origin REquest:在rails中自动完成大学列表
- Spring Ajax列表返回,但对象为空
- 使用AJAX创建数据列表
- 使用Ajax或JavaScript选择下拉列表选项后,在同一页面上执行PHP脚本
- Jquery Selected plugin - 由 Ajax 动态填充列表
- ajax函数更改下拉列表值
- 从填充了 AJAX 的下拉列表中获取控制器的操作方法中的值
- 引导下拉列表动态 ajax 列表项
- ajax/jQuery Youtube 播放列表推送
- 如何使用 ajax 从 sql Server 获取单选按钮的值,并表示列表单选按钮
- 如何传递id列表's在MVC中向服务器发出AJAX请求
- AJAX请求php获取post/get发送的指定目录中服务器上的文件列表(无JQUERY)
- 基于ajax动态定位列表项
- ajax下拉列表
- ajax更新后jQuery列表刷新
- 所选列表元素不会保持选中状态(通过ajax请求更新后)
- JQuery从c#函数返回ajax列表
- 使用JQuery淡出JSON ajax列表
- AJAX列表更新,获取新元素并计数