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

效果图:

div展开与收起(鼠标点击)_第1张图片

div展开与收起(鼠标点击)_第2张图片

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-3999p>
            <p>特点:JDPhone计划‘0’元购机 放水p>
        div>
    div>
    <p class="slide">
        <a href="javascript:showdiv();" id="strHref" class="btn-slide">更多选项+a>
    p>
body>
html>

 

转载于:https://www.cnblogs.com/Harold-Hua/p/5380480.html

你可能感兴趣的:(div展开与收起(鼠标点击))