一:jquery对象与dom对象之间的转换
1:jquery对象转dom对象
(1)方式一:
$(seletor)[0]
(2)方式二
$(selector).grt(0)
2:dom对象转jquery对象
$(对象名)
二:获取元素的尺寸
1:获取content
//获取selector的宽度
$(selector).width()
//获取selector的高度
$(selector).height()
2:获取content+padding
//获取selector的content+padding宽度
$(selector).innerWidth()
//获取selector的content+padding高度
$(selector).innerHeight()
3:获取content+padding+border
//获取selector的content+padding+border宽度
$(selector).outerWidth()
//获取selector的content+padding+border高度
$(selector).outerHeight()
4:获取content+padding+border+margin**
//获取selector的content+padding+border+margin宽度
$(selector).outerWidth(true)
//获取selector的content+padding+border高度
$(selector).outerHeight(true)
三:获取元素的位
1:相对于页面获取坐标 offset() 返回一个对象,可用来设置值和获取元素的值
$(selector).offset({ top: y, left: x })
2:相对于定位来获取坐标,只能读取,不能写入
$(selector).position()
四:jquery获取滚动条的位置
//获取文档向下拉取的高度
$(selector).scrollTop()
//获取文档向左拉取的宽度
$(selector).scrollLeft()
五:jquery动画效果
1:隐藏显示效果
//隐藏
$(selector).hide(speed,fn)
//显示
$(selector).show(speed,fn)
//切换隐藏显示,如果元素显示则隐藏,反之显示
$(selector).toggle(speed,fn)
//speed为效果的事件或者速度,值可以为slow,fast,毫秒
//fn为回执函数
2:淡入淡出
//淡入
$(selector).fadeIn(speed,fn)
//淡出
$(selector).fadeOut(speed,fn)
//切换淡出淡入
$(selector).fadeToggle(speed,fn)
//speed为效果的事件或者速度,值可以为slow,fast,毫秒
//fn为回执函数
3:滑动效果
//滑出
$(selector).slideDown(speed,fn)
//滑入
$(selector).slideUp(speed,fn)
//切换滑出滑入
$(selector).slideToggle(speed,fn)
//speed为效果的事件或者速度,值可以为slow,fast,毫秒
//fn为回执函数
4:animate动画效果
$(selector).animate({params},speed,fn)
//params定义css属性
//speed为效果的事件或者速度,值可以为slow,fast,毫秒
//fn为回执函数
六:chaining链式技术
chaining通俗来讲意味着我们可以在相同元素上运行多条jquery方法而互不冲突