• JS 实现点击展开菜单


    1: 获取事件源的两种方式

    2: overflow 控制展现

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    	<meta http-equiv="pragma" content="no-cache">
    	<meta http-equiv="cache-control" content="no-cache">
    	<meta http-equiv="expires" content="0">    
    	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    	<meta http-equiv="description" content="This is my page">
    	<!--
    	<link rel="stylesheet" type="text/css" href="styles.css">
    	-->
    	
    	 <script type="text/javascript">
      		 // 第二种通过this对象获取时间源
      		function list(node){
      			//alert(""");
      			var dlNode = node.parentNode;
      			var nodes = document.getElementsByTagName("dl");
      			//alert(nodes.length);
      			for (var i = 0; i < nodes.length; ++i) {
      				if (nodes[i] == dlNode) {
      					if (nodes[i].className == "close") {
      						nodes[i].className = "open";
      					} else {
      						nodes[i].className = "close";
      					}
      				} else {
      					nodes[i].className = "close";
      				}
      			}
      		}  
      		/* 第一种通过event获取时间源
      		function list(){
      			var node = event.srcElement;
      			var dlNode = node.parentNode;
      			var nodes = document.getElementsByTagName("dl");
      			//alert(nodes.length);
      			for (var i = 0; i < nodes.length; ++i) {
      				if (nodes[i] == dlNode) {
      					if (nodes[i].className == "close") {
      						nodes[i].className = "open";
      					} else {
      						nodes[i].className = "close";
      					}
      				} else {
      					nodes[i].className = "close";
      				}
      			}
      		} */
      	 </script>
      	 
      	 <style type="text/css">
      	 	.open{
      	 		overflow: visible;
      	 	}
      	 	.close{
      	 		overflow: hidden;
      	 	}
      	 	dl{
      	 		overflow: hidden;
      	 		height: 16px;
      	 	}
      	 </style>
      </head>
     
      
      
      <body>
        <dl>
        	<dt onclick="list(this)">会员管理</dt>
    	    	<dd>添加会员</dd>
    	    	<dd>删除会员</dd>
    	    	<dd>查询会员</dd>
        </dl>
     	<dl>
        	<dt onclick="list(this)">会员管理</dt>
    	    	<dd>添加会员</dd>
    	    	<dd>删除会员</dd>
    	    	<dd>查询会员</dd>
        </dl>
        <dl>
        	<dt onclick="list(this)">会员管理</dt>
    	    	<dd>添加会员</dd>
    	    	<dd>删除会员</dd>
    	    	<dd>查询会员</dd>
        </dl>
        <dl>
        	<dt onclick="list(this)">会员管理</dt>
    	    	<dd>添加会员</dd>
    	    	<dd>删除会员</dd>
    	    	<dd>查询会员</dd>
        </dl>
        <dl>
        	<dt onclick="list(this)">会员管理</dt>
    	    	<dd>添加会员</dd>
    	    	<dd>删除会员</dd>
    	    	<dd>查询会员</dd>
        </dl>
      </body>
    </html>
    

      

  • 相关阅读:
    HCTF2018-admin
    SUCTF 2019-EasySQL
    BUUCTF-WEB-easy_tornado
    黑客攻防技术宝典web实战篇:攻击数据存储区习题
    可持久化数据结构·主席树(静态)
    Luogu P2661 [NOIP2015] 信息传递
    Luogu P2700 逐个击破
    Luogu P4779 【模板】单源最短路径(标准版)(Dijkstra+堆优化模板)
    Luogu P1962 斐波那契数列(矩阵乘法模板)
    Luogu P3366 【模板】最小生成树
  • 原文地址:https://www.cnblogs.com/E-star/p/3681898.html
Copyright © 2020-2023  润新知