day15

it2022-05-08  7

回顾

事件

鼠标clickdblclickcontextmenumouseentermouseleavemousemovemousedownmouseup​键盘keydownkeyupkeypress​表单submitresetblur   失去焦点focus 获取焦点change 绑定在selectselect  input 事实改变 兼容性​文档事件load  unloadbeforeunload​图片事件loadaborterror​其他事件scrollresize ele.on事件 = function(){}ele.addEventListener('事件名', function(){}, true/false) Event对象clientXclientYkeyCodebuttontarget 具体触发事件的元素stopPropagation() 阻止事件冒泡preventDefault() 阻止默认动作

 

BOM

window   window.innerWidth window.inenrHeight​history length back() forward() go()​screen ​location href protocol host hostname port pathname search hash​navigator userAgent

 

DOM

文档对象模型

 

 

day15

jQuery

1. jQuery 的介绍

2. jQuery的基本使用

2.2 文档就绪事件

$(document).ready(function(){    code...})​//简写$(function(){    })

 

2.2 jQueryDOM和原生DOM

jQuery 通过 $(选择器) 获取元素,该元素对象是jqueryDOM。 与原生DOM不同jQueryDOM是在原生DOM基础上进行的的封装,本质上是由原生DOM组成的类数组对象,可以 [索引] 得到原生DOM$(原生DOM) 转为 jQuery DOM​

 

 

3. jQuery 选择器

3.1 基本选择器

同CSS3 基本选择器

3.2 层级选择器

同CSS3的层级选择器

空格>+~

3.3 基本筛选器

:first:last:eq() 从0开始:odd   奇数:even 偶数:lt() 小于   :gt() 大于:not(选择器)

3.4 内容选择器

:contains(text) 包含指定文字的元素:has(选择器)     包含指定子元素的 元素:empty           没哟子元素也没有内容的 元素:parent           有子元素或者有内容 的 元素

3.5 可见性选择器

:hidden:visible

3.6 属性选择器

[attr]   .list img[title][attr=value]   img[title=hello][attr!=val]   不等于[attr^=val][attr$=val][attr*=val] attr属性 包含 val[][][]​注意少了 ~= 和 |=

3.7 子元素选择器

:first-child:first-of-type:last-child:last-of-type:nth-child:nth-last-child():nth-last-of-type():nth-of-type():only-child:only-of-type

3.8 表单选择器

:input 所有的表单控件 input、select、textarea、button:text       input type=text:password:radio:checkbox:submit:reset:button:file

3.9 表单对象选择器

:disabled:enabled 可用的:checked   :selected 定义选中项 option

 

4 jQuery 筛选器

4.1 过滤

eq(index) 从0开始   指定索引值first()             第一个last()             最后一个filter(选择器)     并且符合选择器条件的元素not(选择器)         除了这个选择器之外的所有元素has(选择器)         包含指定选择器的祖先元素slice(start, end) 从当前选择器中 截取

4.2 查找

查找 子元素children([selector]) 子元素find(selector)       后代元素​查找 父元素parent([selector])parents([selector])parentsUntil([selector])offsetParent()​#兄弟元素next([selector]) 后面紧邻的兄弟元素nextAll([selector]) 后面所有的兄弟元素nextUntil([selector]) 后面兄弟元素 指定结束条件prev([selector]) 前面紧邻的兄弟元素prevAll([selector])prevUntil([selector])siblings([selector]) 所有的兄弟元素(除了自己)​#其他closest(selector) 从自己开始往祖先元素找,返回第一个满足条件的

 

4.3 串联

add()addBack()end()

 

转载于:https://www.cnblogs.com/xujinjin18/p/9497594.html


最新回复(0)