js中一种轻量级框架
队列控制
添加属性(方法如下)
attr
addClass
prop
date
position()方法:
offset()返回对象:相对于浏览器的坐标,有left和top两个参数
相对于父级的坐标,但是必须给父级设置position,否则子类一直往上找,直到找到有设置position的父级元素,否则会相对于浏览器(这样,就跟offset()一样了)。
尺寸
width(): 宽度
innerWidth(): 包含内边距
outterWidth(): 包含外边距和边框
height(): 高度
innerHeight(): 包含内边距
outterHeight(): 包含外边距和边框
pageX,pageY:x,y轴坐标。
选择器
:contains(text)返回包含test文本的元素 $("div:has(p)")返回包含p元素的div :parent()返回含有子节点的元素 :empty()
添加元素
内部插入
- append():在什么里面添加什么(添加到集合的最后)
- appendTo():把什么添加到什么
- prepend():在什么里面添加什么
- prependTo()
外部插入
- after()
- before()
- insertBefore()
- insertAfter()
- wrap():添加父元素
- unwrap():移除父元素
- wrapAll():将所有匹配的元素用单个元素包裹起来
- replaceWith(content|fn):将所有匹配的元素替换成指定的HTML或DOM元素。
绑定事件的方法
bind("click",fn)会去遍历
- on("click",fn)最常用的
- click(fn),对动态生成的元素没有效果。
- live("click",fn)绑定的事件对动态的添加属性和对象到页面的元素也有效。存在性能问题,因为所有事件都是绑定在document上面的,每次采用冒泡的方式到body身上
- delegate("input[type=button]","click",fn)
移除事件处理函数off()。
hover(over,out)接收两个参数