<a href="javascript:void(0)" data-url="http://google.com" class="red">
基本上,当用户点击此按钮时,会出现一个带有计时器的灯箱,然后使用data-url转到该URL。这可能吗?
你们如何结合这些论文,
jQuery(document).ready(function(){
var link = document.getElementsByTagName("a")[0];
link.onclick = function(){
$('.lightbox').show();
setTimeout(function(){window.location.href = link.getAttribute("data-url")}, 1000)
}
});
$(function(){
var count = 10;
countdown = setInterval(function(){
$("p.countdown").html(count + " seconds remaining!");
if (count == 0) {
window.location = 'http://google.com';
}
count--;
}, 1000);
});
答案 0 :(得分:0)
真的很简单的例子,应该让你开始。
var link = document.getElementsByTagName("a")[0];
link.onclick = function(){
// make the modal popup here.
alert("imma let you finish but first imma take you to a new webapge in 1 second");
// after the setTimeout go to a new page
setTimeout(function(){window.location.href = link.getAttribute("data-url")}, 1000)
}
<强> Live Demo 强>
(注意现场演示实际上不会因为jsFiddle而转发)