jquery子元素过滤器
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
//所有ul中的第一个li
//$('ul li:first-child').css('backgroundColor', 'yellow');
//$('ul li:last-child').css('backgroundColor', 'yellow');
//$('ul li:first').css('backgroundColor', 'yellow');
//$('ul li:last').css('backgroundColor', 'yellow');
})
})
</script>
</head>
<body>
<input type="button" name="name" value="btn" id="btn"/>
<ul>
<li>香蕉</li>
<li>西瓜</li>
<li>苹果</li>
<li>桔子</li>
<li>橙子</li>
</ul>
<hr color="gray"/>
<ul>
<li>篮球</li>
<li>排球</li>
<li>足球</li>
<li>羽毛球</li>
<li>乒乓球</li>
</ul>
</body>
</html>
jquery子元素过滤器的更多相关文章
- jQuery编程基础精华02(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)
属性.表单过滤器 属性过滤选择器: $("div[id]")选取有id属性的<div> $("div[title=test]")选取title属性为 ...
- 子元素过滤器nth-child解释
jQuery中的子元素过滤器nth-child是指:选取每个父元素下的第index个子元素或者奇偶元素(index从1算起) 这里有几点要注意: 1. index 从1开始算 2. 过滤器filter ...
- jQuery——子元素筛选器
子元素筛选器 名称 :first-child JQ语法 jQuery( "selector:first-child" ) 说明 :first-child选择器用于匹配作为父元素的第 ...
- 一个样例看清楚JQuery子元素选择器children()和find()的差别
近期在我们的hybrid app项目开发中定位出了一个问题.通过这个问题了解下JQuery选择器find()和children()的差别.问题是这种:我们的混合app是一个单页面应用(main.htm ...
- jquery 子元素筛选选择器
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content ...
- jquery 子元素 后代元素 兄弟元素 相邻元素
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content ...
- jquery子元素选择器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- jQuery 子元素选择
对于如下代码片段 如何对河meishi这个div的子DIV呢? <div id="vertical-Menu-meishi" class="J-nav-item& ...
- jquery子元素过滤选择器
:nth-child('索引值')//获取指定元素下的某个子元素的位置,索引从1开始: //偶数行 //$('li:nth-child(even)').addClass ...
随机推荐
- 【u002】数列排序(seqsort)
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 给定一个数列{an},这个数列满足ai≠aj(i≠j),现在要求你把这个数列从小到大排序,每次允许你交 ...
- IDEA使用从Eclipse过来的快捷键
1.Eclipse中的ctrl+shift+o --------> Ctrl + Alt + O 2.Eclipse中快捷键是Ctrl+O ---------> MacOS 下是 cmd+ ...
- [Postgres] Filter Data in a Postgres Table with Query Statements
We have all this data, but how do we answer questions about it? In this lesson we’ll learn how to fi ...
- ssh连接上腾讯云、华为云Linux服务器,一会就自动断开
客户端向服务端发送心跳 依赖 ssh 客户端定时发送心跳,putty.SecureCRT.XShell 都有这个功能. Linux / Unix 下,编辑 ssh 配置文件: # vim /etc/s ...
- 【codeforces 750A】New Year and Hurry
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Erlang入门
Erlang简史(翻译) Erlang入门(二)—并发编程 Erlang入门(三)——分布式编程 Erlang入门(四)——错误处理和鲁棒性 Erlang入门(五)——补遗
- java 保存和读取本地json文件
保存数据到本地文件 private void saveDataToFile(String fileName,String data) { BufferedWriter writer = null; F ...
- cocos2d-x 调色
在游戏开发.我们须要实现闪光的灯.照明弹效果等等,我么你能够採用混合模式来实现. 假设学习过OpenGL(ES),就知道里面使用glBlendFunc函数实现的.在cocos2d-x里肯定也有,对于精 ...
- Js跨域小总结
教程 以下的例子包含的文件均为为http://www.a.com/a.html.http://www.a.com/c.html 与http://www.b.com/b.html ,要做的都是从a.ht ...
- less循环写css工具类
//margin-right=================.mr(100); .mr(@n, @i: 1) when (@i =< @n) { .mr-@{i} { margin-right ...