jqury---单击时我们改变样式

<%@ 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>单击时我们改变样式</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">
	-->
   <style type="text/css">
      #menu{
         width: 300px;
         }
                               //在css中编写#代表id   .代表class
      .classchild{
         background:yellow;
      }  
      
      hd{
          background:gray;
      }
      div{
        padding: 0;  margin: 10px 0;
       }
       
       div a{
         background:green;
       }
   </style>
   <script type="text/javascript" src="jqury/jquery-1.8.2.min.js"></script>
  </head>
  
  <body>
     <div id="menu">
        <span> 第一章   做人的基础</span>
        <a>原则</a>
        <a>方法</a>
        <a>总结</a>
     </div>
     
     <div class="classchild">
       <span>第二章   做人的准则</span>
       <a>原则</a>
        <a>方法</a>
        <a>总结</a>
     </div>
     
     <div class="classchild">
       <span>第三章  学会说话</span>
       <a>原则</a>
        <a>方法</a>
        <a>总结</a>
     </div>
     
     <script type="text/javascript">
        $(".classchild").click(function(){  //获得类名为classchild的元素集  添加单击事件
             $("this").addClass("hd")       //为当前集中对象添加hd类名 
                      .children("a").show()          //把当前对象的的a都显示出来
                      .end()                     //重新定位到上次操作的元素
                      .siblings()                //获得兄弟节点
                             .removeClass("hd")  //移除兄弟节点的hd类
                             .childern("a")      //获得兄弟节点的  a元素
                                     .hide();    //隐藏
                    
        })
        
     </script>
  </body>
</html>
代码未经检测    只提供思想


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值