點擊縮圖在指定的地方顯示對應的大圖!

來源:互聯網
上載者:User
產品頁面,點擊產品名稱進入產品詳細頁面.因為上傳的時候就是同時傳三張大圖,然後再產生三張小的縮圖,三張大圖和對應的三張縮圖的檔案名稱都寫進了資料庫.在查看產品詳細資料的時候,上面三張小的是從資料庫直接讀出來的,然後剩下的就是在三張小圖的下面的一個表的儲存格中顯示大圖,條件是:點擊縮圖,在儲存格顯示對應的大圖!

  請問如何?點擊小圖片,可以在下面的表格上顯示出相關的大圖片?
  小圖片與大圖片的檔案名稱的關係為:

  想要的效果如:

  小圖片1  |    小圖片2  |    小圖片3

  |---------------------------------|
  |                                                                  |
  |                                                                  |
  |              大        圖        片                        |
  |                                                                  |
  |                                                                  |
  |---------------------------------|

實現方法(以下代碼是我的一個朋友菜菜寫的,轉載請註明,結合自身用的語言發揮!)
<!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>
<script type="text/javascript">
function showPic(whichpic)
{
    var source = whichpic.getAttribute("href");
    var placeholder = document.getElementById("placeholder");
    placeholder.setAttribute("src",source);   
}
</script>
</head>
<body>
<ul>
    <li><a href="images/01.jpg" onclick="showPic(this); return false;"><img src="images/01.jpg" /></a></li>
    <li><a href="images/02.jpg" onclick="showPic(this); return false;"><img src="images/02.jpg" /></a></li>
    <li><a href="images/03.jpg" onclick="showPic(this); return false;"><img src="images/03.jpg" /></a></li>
</ul>
<img id="placeholder" src="images/01.jpg" alt="my image gallery" />
</body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.