图片名称查看图片(前进后退)功能

在写这篇文章之前,xxx已经写过了几篇关于改图片名称主题的文章,想要了解的朋友可以去翻一下之前的文章

    注:images件文夹下图片的定名是从1~5.jpg有法则的

           声明的  var array = [1, 2, 3, 4, 5]; 这个数组放存的是图片的名称

    <head>

    每日一道理
天又快黑了,这座忙碌的城市又将入睡,让这劳累的“身躯”暂别白日的辛勤,让它入睡,陪伴着城市中的人们进入梦乡。当空的弯月正深情地注视着这座城市与城市中的人们,看着家家户户的灯渐渐熄灭,它在床头悄悄奏响“明月曲”……

    <title></title>
    <script src="Jquery1.7.js" type="text/javascript"></script>
    <style type="text/css">
        img
        {
            width: 200px;
            height: 200px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            var array = [1, 2, 3, 4, 5];
            var count = 0;
            $('#Button1').click(function () {
                if (count > 0) {
                    count--;
                    $('img').attr('src','images/'+array[count]+'.jpg');
                }
            })


            $('#Button2').click(function () {
                if (count <4) {
                    count++;
                    $('img').attr('src', 'images/' + array[count] + '.jpg');
                }
            })


        })
    
    </script>
</head>
<body>
    <table>
        <tr>
            <td>
                <input id="Button1" type="button" value="<" />
            </td>
            <td>
                <img src="images/1.jpg" />
            </td>
            <td>
                <input id="Button2" type="button" value=">" />
            </td>
        </tr>
    </table>
</body>

文章结束给大家分享下程序员的一些笑话语录: 人在天涯钻,哪儿能不挨砖?日啖板砖三百颗,不辞长做天涯人~

posted @ 2013-04-23 20:19  xinyuyuanm  阅读(146)  评论(0编辑  收藏  举报