码迷,mamicode.com
首页 > 其他好文 > 详细

div展开与收起(鼠标点击)

时间:2016-04-11 23:50:46      阅读:467      评论:0      收藏:0      [点我收藏+]

标签:

效果图:

技术分享

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>展开与收起</title>
    <style type="text/css">
        body{
            margin: 0 auto;
            padding: 0;
        }
        #pn{
            background: #e8e8e8;
            width: 600px;
            display: block;
            margin: 0 auto;
            padding: 5px;
            font-size: 9pt;
            height: auto;
        }
        .slide{
            margin: 0 auto;
            padding: 0;
            width: 600px;
            border-top: 4px solid gray;
        }
        .btn-slide{
            background: gray;
            width:120px;
            height: 30px;
            text-align: center;
            margin: 0 auto;
            display: block;
            color: #fff;
            text-decoration: none;
            padding-top: 10px;
        }
    </style>
    <script type="text/javascript">
    function showdiv(){
        document.getElementById("hpn").style.display="block";
        document.getElementById("strHref").innerHTML="收起-";
        document.getElementById("strHref").href="javascript:hidediv()";
    }
    function hidediv(){
        document.getElementById("hpn").style.display="none";
        document.getElementById("strHref").innerHTML="更多选项+";
        document.getElementById("strHref").href="javascript:showdiv()";
    }
    </script>
</head>
<body>
    <div id="pn">
        <p>手机商品筛选</p>
        <p>网络:移动 联通 电信</p>
        <div id="hpn" style="display:none">
            <p>价格:5000以上 4000-4999 3000-3999</p>
            <p>特点:JDPhone计划‘0’元购机 放水</p>
        </div>
    </div>
    <p class="slide">
        <a href="javascript:showdiv();" id="strHref" class="btn-slide">更多选项+</a>
    </p>
</body>
</html>

 

div展开与收起(鼠标点击)

标签:

原文地址:http://www.cnblogs.com/Harold-Hua/p/5380480.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!