JavaScript+CSS互動

來源:互聯網
上載者:User

標籤:

當滑鼠移動到小圖片上時,小圖片顯示紅色邊框並在上面大圖片顯示相應大圖片,效果

<!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><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><style type="text/css">#div{width:500px;height:500px;border:1px solid #fff;margin:auto;background:#fff}li{list-style:none;float:left;margin-top:-15px;margin-left:50px}</style></head><body><div id="div"><div style="width:350px;height:262px;border:1px solid #fff;margin:auto;">  <img src="images/show1_big.jpg" width="349" height="262" /> </div><div style="width:500px;height:50px;border:1px solid #fff;margin-top:180px"><!--ul開始--><ul>  <li><img src="images/show1.jpg" width="53" height="46" onmouseover="change()"/> </li>    <li><img onmouseover="change1()" src="images/show2.jpg" width="53" height="46" /> </li>    <li><img src="images/show3.jpg" width="53" height="46" onmouseover="change2()"/> </li>    <li><img src="images/show4.jpg" width="53" height="46" onmouseover="change3()" /> </li>  </ul>            <!--ul結束-->  </div></div></body><script type="text/javascript">//定義function kuang(){        var getli=document.getElementsByName("li");    for(var i=0;i<getli.length;i++){                            }            }              //定義替換圖片方法function change(){    var imgs=document.getElementsByTagName("img");    imgs[0].setAttribute("src","images/show1_big.jpg");    imgs.style.width="border:1px solid red";    }     //定義替換圖片方法    function change1(){    var imgs=document.getElementsByTagName("img");    imgs[0].setAttribute("src","images/show2_big.jpg");    }         //定義替換圖片方法        function change2(){    var imgs=document.getElementsByTagName("img");    imgs[0].setAttribute("src","images/show3_big.jpg");    }         //定義替換圖片方法    function change3(){    var imgs=document.getElementsByTagName("img");    imgs[0].setAttribute("src","images/show4_big.jpg");    }            </script></html>

 

JavaScript+CSS互動

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.