我在我的网站上有一块js来切换图像但是当你第二次点击图像时需要延迟.延迟应该是1000毫秒.所以你会点击img.jpg然后会出现img_onclick.jpg.然后,您将单击img_onclick.jpg图像,然后在再次显示img.jpg之前应该延迟1000毫秒.
这是代码:
jQuery(document).ready(function($) {
$(".toggle-container").hide();
$(".trigger").toggle(function () {
$(this).addClass("active");
$(".trigger").find('img').prop('src', 'http://localhost:8888/images/img_onclick.jpg');
}, function () {
$(this).removeClass("active");
$(".trigger").find('img').prop('src', 'http://localhost:8888/images/img.jpg');
});
$(".trigger").click(function () {
$(this).next(".toggle-container").slideToggle();
});
});
Run Code Online (Sandbox Code Playgroud)