用jquery<script type="text/javascript">
$(document).ready(function() {
  $('#btn').click(function() {
      $('#img').attr('src', 'your image src'); 
  });
});
</script>

解决方案 »

  1.   

    你好 我没有jQuery的基础,能简单解释一下吗?谢谢!!
      

  2.   

    如果你不会jquery,基本的javascript总会吧document.getelmentbyid("picid").src = "xxxxx"
      

  3.   

    楼上方法可行,在写2个判断,if当前body背景等于第一张背景就显示第二张背景,else第一张
      

  4.   

    ready event: html文档载入完成的16:33
    http://api.jquery.com/ready/click event:这里是点击按钮的事件
    http://api.jquery.com/click/attr function: 修改一个element的attribute的值,这里是就该img element的src 的值。
    http://api.jquery.com/attr/
      

  5.   

    版主大哥 提示:无法设置src的值 对象为null或者未定义 是什么原因??谢谢
      

  6.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script>
            function Test() {
                if (document.getElementById("bgImg").style.backgroundImage.indexOf('Jellyfish.jpg') > 0) {
                    document.getElementById("bgImg").style.backgroundImage = "url('bg_img.jpg')";
                }
                else {
                    document.getElementById("bgImg").style.backgroundImage = "url('Jellyfish.jpg')";
                }        }
        </script>
    </head>
    <body id="bgImg" >    <form id="form1" runat="server">
        <div>
        <input type="button" id="btn" onclick="javascript:Test();" value="更换" />
        </div>
        </form>
    </body>
    </html>
      

  7.   

    你好 测试了一下 提示:无法获取属性style的值 对象为null或未定义 是什么原因??谢谢!
      

  8.   

    多谢各位!http://www.cnblogs.com/still-windows7/archive/2011/10/17/2215498.html