关于jquery你不知道的知识

一: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方法而互不冲突

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值