zoukankan      html  css  js  c++  java
  • javascript图片库威力增强版

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link rel="stylesheet" href="layout.css" media="screen"/>
    </head>

    <body onload="countBodyChildren()">
    <h1>Snapshots</h1>
    <ul>
    <li><a href="Blue hills.jpg" onclick="showPic(this);return false;" title="the mountain of blue">山峦</a></li>
    <li><a href="Sunset.jpg" onclick="showPic(this);return false;" title="red enjoy it">日出</a></li>
    <li><a href="Water lilies.jpg" onclick="showPic(this);return false;" title="a summer flower">荷花</a></li>
    <li><a href="Winter.jpg" onclick="showPic(this);return false;" title="a white world">雪林</a></li>
    </ul>
    <img id="placeholder" src="gallery.JPG" alt="my image gallery"/>
    <p id="description">Choose an image</p>
    <script type="text/javascript" src="showPic.js"></script>
    </body>
    </html>

    showPic.js

    function showPic(whichpic){
        var source=whichpic.getAttribute("href");
        var placeholder=document.getElementById("placeholder");
        placeholder.setAttribute("src",source);
        var text=whichpic.getAttribute("title");
        var description=document.getElementById("description");
        description.firstChild.nodeValue=text;
    }

    layout.css

    @charset "utf-8";
    /* CSS Document */

    body{
        font-family:Arial, Helvetica, sans-serif;
        color:#333;
        font-family:"新宋体";
        background-color:#ccc;
    }
    h1{
        color:#333;
        background-color:transparent;
    }
    a{
        color:#c60;
        background-color:transparent;
        font-weight:bold;
        text-decoration:none;
    }
    ul{
        padding:0;
    }
    li{
        float:left;
        padding:1em;
        list-style:none;
    }
    img{
        display:block;
        clear:both;
    }

  • 相关阅读:
    C++中虚继承的作用
    游戏程序设计学习初窥简单DirectX代码实现
    vue4.x更改默认端口 larry
    Visual studio 2010几个比较酷的功能
    Web前端编程:勿混淆NodeList与Array
    代码规范之署名
    一则中文文件名引起的问题
    C# WebService调用及数据并行处理
    2010年终总结
    关于DotNetNuke
  • 原文地址:https://www.cnblogs.com/daochong/p/4843123.html
Copyright © 2011-2022 走看看