I have this a piece of js in my website to switch images but need a delay when you click the image a second time.(我在我的网站上有一块js来切换图像但是当你第二次点击图像时需要延迟。)
The delay should be 1000ms.(延迟应该是1000毫秒。) So you would click the img.jpg then the img_onclick.jpg would appear.(所以你会点击img.jpg然后会出现img_onclick.jpg。) You would then click the img_onclick.jpg image there should then be a delay of 1000ms before the img.jpg is shown again.(然后,您将单击img_onclick.jpg图像,然后在再次显示img.jpg之前应该延迟1000毫秒。) Here is the code:(这是代码:)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();
});
});
ask by Blue Orange translate from so