小编Cra*_*rax的帖子

'x'时间后javascript图像发生变化

我将如何为此js添加计时器,以便在'x'时间后图像会自动更改.目前,通过带有'rel'属性的'a href'进行更改,但仍需要具有'rel'的功能.

JS:

$(document).ready(function (){
    $('#button a').click(function(){
        var integer = $(this).attr('rel');
        $('#myslide .cover').css({left:-1476*(parseInt(integer)-1)}).hide().fadeIn(); /*----- Width of div mystuff (here 160) ------ */
        $('#button a').each(function(){
        $(this).removeClass('active');
            if($(this).hasClass('button'+integer)){
                $(this).addClass('active')}
        });
    }); 
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<div id="myslide">
<div class="cover">

    <div class="mystuff">
        <img src="images/header_01.jpg" rel="1"></img>
        <img src="images/header_02.jpg" rel="1"></img>
        <img src="images/header_03.jpg" rel="1"></img>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript image timer

3
推荐指数
1
解决办法
6665
查看次数

标签 统计

image ×1

javascript ×1

timer ×1