0

我想知道是否有人有过时间延迟的经验?我试图让我的所有全球链接延迟打开。只是为了给它一个艺术效果,让它更顺畅地交换页面。但由于某种原因,我无法让它工作。我会很感激我能得到的任何帮助。

HTML:

    <!DOCTYPE html>
<html lang="en-US">
    <head>
    <meta charset="utf8" />
        <link rel="stylesheet" type="text/css" media="all" href="css/mainstyle.css"/>
        <meta name="viewport" content="initial-scale=1" />
        <title> Redneck Rampage </title>
    </head>
    <body class="filter">
    <div id="background"> 
        <div id="wrapper">
            <div class="navigation">
                <ul id="mainmenu">
                    <li class="active"><a href="index.html">Home</a></li>   
            <li><a href="band.html">Band</a></li>  
            <li><a href="news.html">News</a></li>
                    <li><a href="shows.html">Shows</a></li>
                    <li><a href="music.html">Music</a></li>
                    <li><a href="gallery.html">Gallery</a></li>
                    <li><a href="media.html">Media</a></li>
                    <li><a href="store.html">Store</a></li>

                </ul>
            </div>

                <div class="footer homepage">
                    <p class="rednecks">Website and Contents &copy; Redneck Rampage 2013. </p>
                    <p class="signature">Designed by Martin Metsalu </p>

                        <ul id="footermenu">
                            <li><a href="terms.html">Terms of use</a></li>
                            <li><a href="privacy.html">Privacy Policy</a></li>
                            <li><a href="contact.html">Contact</a></li>
                       </ul>
                    <div class="socialplugins">
                        <div class="test"><a href="#"><img src="IMG/soundcloud.png" alt="plugin#1" ></a></div>        
                        <div class="test"><a href="#"><img src="IMG/youtube.png" alt="plugin#2"></a></div>
                        <div class="test"><a href="#"><img src="IMG/myspace.png" alt="plugin#3"></a></div>
                        <div class="test"><a href="#"><img src="IMG/facebook.png" alt="plugin#4"></a></div>

                    </div>

                </div>
         </div>
    </div>
</body>
</html>

查询:

        $('a').click(function(e) {
$('a[href*="/steve"]').each(function(index) {
    setTimeout(
         function(href){window.open(href)},
         (index+1)*5000, $(this).attr('href')
    );
});
4

2 回答 2

1
$( 'a[href*="/steve"]' ).each( function () {
    $( this ).on( 'click', function ( event ) {
        event.preventDefault();
        ( function ( h ) {
            setTimeout( function () {
                window.location = h;
            }, 5000 );
        })( this.href );
    });
});

试试看。

于 2013-01-15T00:00:30.917 回答
0

我认为你只需要e.preventDefault();在点击功能的顶部做

于 2013-01-14T23:57:15.020 回答