<div class="codetitle"> <span><a style="CURSOR: pointer" data="15874" class="copybut" id="copybut15874" onclick="doCopy('code15874')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code15874"> <br> <br><br><br> <title></title> <br> <style type="text/css"><BR> img<BR> {<BR> width:200px; height:200px;<BR> }<BR> </style> <br> <script src="jquery-1.9.1.js" type="text/javascript"></script><br> <script type="text/javascript"><BR> $(function () {<BR> $('#btn1').click(function () {<BR> var num = Math.floor(Math.random() * 8 + 1);<BR> $('img').attr('src','picture/'+num+'.jpg')<BR> })<BR> })<BR> </script><br><br><br><img src="picture/1.jpg" id="img1" alt="jQuery随机切换图片的小例子_jquery" ><br><input id="btn1" type="button" value="变换"><br><br><br> </div>