左侧菜单收缩的实现(包括,筛选器,addclass、removeclass、绑定事件,链式编程)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.head{
background-color: #2f96b4;
color: red;
}
.content{
min-height: 80px;
background-color: green;
}
.hide{
display: none;
}
</style>
</head>
<body>
<div style="height: 400px;width: 200px;border: 1px solid #DDDDDD">
<div class="item">
<div class="head">标题1</div>
<div id="i1" class="content hide">内容1</div>
</div>
<div class="item">
<div class="head">标题2</div>
<div id="i2" class="content hide">内容1</div>
</div>
<div class="item">
<div class="head">标题3</div>
<div id="i3" class="content hide">内容1</div>
</div>
<div class="item">
<div class="head">标题4</div>
<div id="i4" class="content hide">内容1</div>
</div>
</div>
<script src="jquery.js"></script>
<script>
$('.head').click(function () {
$(this).next().removeClass('hide').parent().siblings().find('.content').addClass('hide');
// 当前点击的标签 $(this)
// 获取某个标签的下一个标签
// 获取某个标签的父标签
// 获取所有的兄弟标签
// 添加样式和移除样式
// $('.i1').addClass('hide')
// $('#i1').removeClass('hide')
// var v = $("this + div");
// $("label + input")
// console.log(v);
//
// $("afsldkfja;skjdf;aksdjf") // 筛选器
/*
$(this).next() 下一个
$(this).prev() 上一个
$(this).parent() 父
$(this).children() 孩子
$('#i1').siblings() 兄弟
$('#i1').find('#i1') 子子孙孙中查找
// . . .
//
$('#i1').addClass(..)
$('#i1').removeClass(..)
*/ // 链式编程
// $(...).click(function(){
// this..
// }) // $(this).next().removeClass('hide');
// $(this).parent().siblings().find('.content').addClass('hide') })
</script>
</body>
</html>
左侧菜单收缩的实现(包括,筛选器,addclass、removeclass、绑定事件,链式编程)的更多相关文章
- jQuery支持链式编程,一句话实现左侧table页+常用筛选器总结
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- jQuery 筛选器 链式编程操作
$('#i1').next() 下一个标签$('#i1').nextAll() 兄弟标签中,所有下一个标签$('#i1').nextUntil('#ii1') 兄弟标签中,从下一个标签到id为ii1的 ...
- jquery选择器,筛选器,属性,事件 基础
左边栏实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...
- JQuery怎么实现页面左侧菜单刷新后保留鼠标点击addclass的样式?
$('ul.main-menu li a').each(function(){ if($($(this))[0].href==String(window.location)) $(this).pare ...
- 链式编程:遇到多个构造器参数(Constructor Parameters)时要考虑用构建器(Builder)
public class NutritionFacts { private final int servingSize; private final int servings; private fin ...
- jQuery---jq基础了解(语法,特性),JQ和JS的区别对比,JQ和JS相互转换,Jquery的选择器(基础选择器,层级选择器,属性选择器),Jquery的筛选器(基本筛选器,表单筛选器),Jquery筛选方法
jQuery---jq基础了解(语法,特性),JQ和JS的区别对比,JQ和JS相互转换,Jquery的选择器(基础选择器,层级选择器,属性选择器),Jquery的筛选器(基本筛选器,表单筛选器),Jq ...
- jQuery初识之选择器、样式操作和筛选器(模态框和菜单示例)
一.jQuery 1.介绍 jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架). jQuery设计的 ...
- jQuery查找标签--选择器,筛选器,模态对话框, 左侧菜单栏
查找标签 选择器: 基本选择器(同css) id选择器 $("#id") 标签选择器 $('tagName') class选择器 $(".className") ...
- jQuery 选择器 筛选器 样式操作 文本操作 属性操作 文档处理 事件 动画效果 插件 each、data、Ajax
jQuery jQuery介绍 1.jQuery是一个轻量级的.兼容多浏览器的JavaScript库. 2.jQuery使用户能够更方便地处理HTML Document.Events.实现动画效果.方 ...
随机推荐
- (转)Centos7下杀毒软件clamav的安装和使用
本文转载自:https://www.cnblogs.com/bingo1024/p/9018212.html#_label1_0 目录 一.yum安装 二.编译安装 2.1:下载软件包 2.2:创建c ...
- java通过图片URL下载图片
public InputStream getInputStream(String imgUrl) { InputStream inputStream = null; try{ HttpURLConne ...
- 使用Node,Vue和ElasticSearch构建实时搜索引擎
(译者注:相关阅读:node.js,vue.js,Elasticsearch) 介绍 Elasticsearch是一个分布式的RESTful搜索和分析引擎,能够解决越来越多的用例. Elasticse ...
- SpringBoot---异步消息
1.概述 1.1.SpringBoot 对 JMS 的自动配置 位于 org.springframework.boot.autoconfigure.jms下: 1.2.SpringBoot 支 ...
- Conservation Vs Non-conservation Forms of conservation Equations
What does it mean? The reason they are conservative or non-conservative has to do with the splitting ...
- 利用xcode Build生成模拟器运行包
真机只能运行.ipa包 模拟器上只能运行.app包 xcode中生成.app包步骤: 启动xcode IDE,打开gigold源码工程 [project]——[gigold]——[Basic]:修改V ...
- 6,Stack
一,Stack简介 Stack是栈.它的特性是:先进后出(FILO, First In Last Out). java工具包中的Stack是继承于Vector(矢量队列)的,由于Vector是通过数组 ...
- .net core跨平台
https://www.cnblogs.com/artech/p/7812811.html .net简介:https://baike.baidu.com/item/.NET/156737?fr=ala ...
- CTF_知识点网址收藏
杂项 图片 python lsb.py extract big.png-stego.png3.txt详解 : https://www.4hou.com/technology/2515.html :h ...
- 转载:TypeError: Cannot read property 'compilation' of undefined vue 打包运行npm run build 报错
转载自:https://www.jianshu.com/p/3f8f60e01797 运行npm run build打包时,报错如下: 我的package.json如下: { ... " ...