jQuery随机切换图片的小例子

来源:互联网 发布:工程规范查询软件 编辑:程序博客网 时间:2024/04/29 18:22

jQuery随机切换图片的小例子

作者: 字体:[增加 减小] 类型:转载
jQuery随机切换图片的小例子,需要的朋友可以参考一下
<iframe id="cproIframe_u1892994_2" width="580" height="90" src="http://pos.baidu.com/acom?adn=3&amp;at=231&amp;aurl=&amp;cad=1&amp;ccd=24&amp;cec=GBK&amp;cfv=17&amp;ch=0&amp;col=zh-CN&amp;conBW=0&amp;conOP=1&amp;cpa=1&amp;dai=2&amp;dis=0&amp;ltr=http%3A%2F%2Fwww.jb51.net%2Farticle%2F66282.htm&amp;ltu=http%3A%2F%2Fwww.jb51.net%2Farticle%2F35710.htm&amp;lu_161=0&amp;lunum=6&amp;n=jb51_cpr&amp;pcs=1306x760&amp;pis=10000x10000&amp;ps=490x188&amp;psr=1440x900&amp;pss=1306x491&amp;qn=ad08d21cc3efd179&amp;rad=&amp;rsi0=580&amp;rsi1=90&amp;rsi5=4&amp;rss0=%23FFFFFF&amp;rss1=%23F7FCFF&amp;rss2=%230000ff&amp;rss3=%23444444&amp;rss4=%23008000&amp;rss5=&amp;rss6=%23e10900&amp;rss7=&amp;scale=&amp;skin=tabcloud_skin_3&amp;stid=5&amp;td_id=1892994&amp;titFF=%E5%AE%8B%E4%BD%93&amp;titFS=12&amp;titTA=left&amp;tn=text_default_580_90&amp;tpr=1432025592996&amp;ts=1&amp;version=2.0&amp;xuanting=0&amp;dtm=BAIDU_DUP2_SETJSONADSLOT&amp;dc=2&amp;di=u1892994&amp;ti=jQuery%E9%9A%8F%E6%9C%BA%E5%88%87%E6%8D%A2%E5%9B%BE%E7%89%87%E7%9A%84%E5%B0%8F%E4%BE%8B%E5%AD%90_jquery_%E8%84%9A%E6%9C%AC%E4%B9%8B%E5%AE%B6&amp;tt=1432025592969.389.754.755" align="center,center" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true"></iframe>
复制代码代码如下:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
    img
    {
       width:200px; height:200px;
        }
    </style>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#btn1').click(function () {
                var num = Math.floor(Math.random() * 8 + 1);
             $('img').attr('src','picture/'+num+'.jpg')
            })
        })
    </script>
</head>
<body>
<img src="picture/1.jpg" id="img1" />
<input id="btn1" type="button" value="变换" />
</body>
</html>
0 0
原创粉丝点击