效果图:
<!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>
时间: 2024-10-13 22:02:26