Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我将如何添加弹出图像的时间限制_Javascript_Html_Css - Fatal编程技术网

Javascript 我将如何添加弹出图像的时间限制

Javascript 我将如何添加弹出图像的时间限制,javascript,html,css,Javascript,Html,Css,单击小图像时,它将弹出15秒,然后自动打开第二个图像 是否可以添加弹出图像的特定时间限制,然后打开下一个图像?与Whatsapp或Facebook状态非常相似 以下是我的HTML、CSS和JavaScript代码: $(函数(){ “严格使用”; $(“.popup img”)。单击(函数(){ var$src=$(this.attr(“src”); $(“.show”).fadeIn(); $(“.img show img”).attr(“src”,$src); }); $(“span,.o

单击小图像时,它将弹出15秒,然后自动打开第二个图像

是否可以添加弹出图像的特定时间限制,然后打开下一个图像?与Whatsapp或Facebook状态非常相似

以下是我的HTML、CSS和JavaScript代码:

$(函数(){
“严格使用”;
$(“.popup img”)。单击(函数(){
var$src=$(this.attr(“src”);
$(“.show”).fadeIn();
$(“.img show img”).attr(“src”,$src);
});
$(“span,.overlay”)。单击(函数(){
$(“.show”).fadeOut();
});
});
.popup{
宽度:900px;
保证金:自动;
文本对齐:居中
}
.弹出式img{
宽度:200px;
高度:200px;
光标:指针
}
.表演{
z指数:999;
显示:无;
}
.show.overlay{
宽度:100%;
身高:100%;
背景:rgba(0,0,0,66);
位置:绝对位置;
排名:0;
左:0;
}
.show.img show{
宽度:600px;
高度:400px;
背景:#FFF;
位置:绝对位置;
最高:50%;
左:50%;
转换:翻译(-50%,-50%);
溢出:隐藏
}
.img显示范围{
位置:绝对位置;
顶部:10px;
右:10px;
z指数:99;
光标:指针;
}
.img显示img{
宽度:100%;
身高:100%;
位置:绝对位置;
排名:0;
左:0;
}
/*端部样式*/

X

您可以使用此代码,但我想您可以在谷歌上轻松找到更多相关示例

$(function() {
  "use strict";

  var timeOut;
  var intervalMs = 15000;
  $(".popup img").click(function() {
     var src = $(this).attr("src");
     $(".show").fadeIn();
     $(".img-show img").attr("src", src);
     if (timeOut != null)
         clearTimeout(timeOut);
     var that = $(this);
     timeOut = setTimeout(function() {
         if (that.next() == null)
             that.siblings().first().click();
         else
             that.next().click();
     }, intervalMs);
  });

  $("span, .overlay").click(function() {
     clearTimeout(timeOut);
     $(".show").fadeOut();
  });
});
$(function() {
  "use strict";

  var timeOut;
  var intervalMs = 15000;
  $(".popup img").click(function() {
     var src = $(this).attr("src");
     $(".show").fadeIn();
     $(".img-show img").attr("src", src);
     if (timeOut != null)
         clearTimeout(timeOut);
     var that = $(this);
     timeOut = setTimeout(function() {
         if (that.next() == null)
             that.siblings().first().click();
         else
             that.next().click();
     }, intervalMs);
  });

  $("span, .overlay").click(function() {
     clearTimeout(timeOut);
     $(".show").fadeOut();
  });
});