1.原生js下的元素尺寸
- window.getComputedStyle(元素).width ==>内容
- 元素.clientWidth ==>内容+padding
- 元素.offsetWidth ==>内容+padding+border
2.jquery下的元素尺寸
jquery元素尺寸
$('div').width()
$().offset()
=>元素相对页面位置, 以对象形式返回 {left:xx, top:yy}
$().offset().left
$().offset().top
$().offset({left:200,top:300})
=> 设置元素位置
$().position()
=> 相对父元素位置
=> 父元素定位
=> 不能设置值
3.操作元素的宽高
$().css({width:'100px',height:'100px'})
$().css(width:'100px')
$().css({top:xx, left:yy})
$('div').width() //不包括padding和border
$('div').innerWidth() //padding
$('div').outerWidth() //padding+border
$('div').outerWidth(true) //padding+border+margin
4. jquery使用ajax
- $.get() 方法
- $.post() 方法
- $.ajax()方法
- $.ajax()方法 发送jsonp请求
5.jquery拓展
- 扩展jquery自身
- 扩展给元素集
- jquery中$与$.fn的区别是什么?