首页 技术 正文
技术 2022年11月19日
0 收藏 946 点赞 3,317 浏览 1526 个字

  筛选选择器(方法)

    既然是方法 那就应该对象调用   obj.metch();

    $(“.dd”).children(“ul”),show();           //找到.dd下的带Ul的所有子元素  显示

        .eq(index)    //匹配index下标的元素

        .first()      //获取第一元素

        .last()      //获取最后一个元素

        .find()      //后代查找

        .parent()    //查找父标签

        .siblings()    //兄弟元素

        .next()    //下一个兄弟元素

        .prev()    //前一个兄弟元素

        .

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="jquery1.12/jquery-1.12.4.js"></script>
<title>Document</title>
</head>
<body> <style>
.li>a{
text-decoration: none;
display: block;
width: 140px; }
ul{
list-style: none;
}
.box>ul>li{
float: left;
margin: 50px; }
.box{
display: block;
height: 30px;
text-align: center;
}
.ul{ padding-left: 0;
text-align: center;
} .li>ul{
display: none;
}
</style> <div class="box">
<ul class="ul">
<li class="li">
<a href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >公司简介</a>
<ul class="ul">
<li>二级菜单选项</li>
<li>二级菜单选项</li>
<li>二级菜单选项</li>
</ul>
</li>
<li class="li">
<a href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >招聘中心</a>
<ul class="ul">
<li>二级菜单选项</li>
<li>二级菜单选项</li>
<li>二级菜单选项</li>
</ul>
</li>
<li class="li">
<a href="" rel="external nofollow" rel="external nofollow" rel="external nofollow" >联系方式</a>
<ul class="ul">
<li>二级菜单选项</li>
<li>二级菜单选项</li>
<li>二级菜单选项</li>
</ul>
</li>
</ul>
</div> <script>
//当我们鼠标移动到.box>ul>li 这个元素的时候 显示它下面的ul 为什么?
//如果我们不把.box>ul>li 元素设置事件 ,放我们把鼠标放在这个元素后 就会隐藏了
$(".box>ul>li").mouseover(function(){
//$(this),因为this是DOM对象,所以需要转换
//children 是获取所有的子元素, a 和ul
//但是我们只需要ul 所以 children("ul"),show()
$(this).children("ul").show();
});
$(".box>ul>li").mouseout(function(){
$(this).children("ul").hide();
}); </script>
</body>
</html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898