我想用jquery做一个img来保持x时间,例如,1秒,然后消失,当你再次点击按钮时,它再次出现并再次消失,依此类推......
我的代码是这样的:
var counter = 1;
var limit = 6;
function addInput(divName) {
if (counter == limit) {
alert("Sólo puedes añadir " + counter + " imágenes");
$( "#loading" ).replaceWith( "<img class='loading' src='Imagenes/exito.png'>" );
} else {
var $images = $('.popupimg');
var template = $('#template').html();
template = template.replace(/{n}/g, $images.children().length +1);
$images.append(template);
counter++;
}
$('#loading').html("<img class='loading' src='Imagenes/cargando.gif'>");
$('.jcarouselimgs').jcarousel('reload', {
animation: 'slow'
});
}
按钮功能和出现图像就像一个魅力,但我只想显示卡甘多和退出图像停留 1 秒。
我该怎么做?
您可以向按钮添加单击事件。 如下所示。
$('div').delay(2000).show(0);
$('span').delay(3000).hide(0);
$('#btn1').click(function (){
$('span').delay(2000).show(0).delay(3000).hide(0);
});
小提琴:http://jsfiddle.net/MMsML/
也许与
$('#some-id').delay(1000).show / fadeIn / replace.. what you want()