1. 程式人生 > >獲取位置

獲取位置

create you .html 位置 text eat api out 元素

獲取標簽位置:1.
var position = $(‘p‘).position();
$(‘p‘).html(‘left:‘+position.left+‘,top:‘+position.top)

獲取區域高度:
2.$(‘p‘).text(‘innerHeight:‘+$(‘p‘).innerHeight())
3.$(‘p‘).text(‘outerHeight:‘+$(‘p‘).outerHeight()+‘,outerHeight(true):‘+$(‘p‘).outerHeight(true):)

4.$(‘p‘).wrapInner(document.createElement(‘b‘))//對標簽內的文字進行加粗
5.<p>Hello</p>how are<p>you?</p>
$(‘p‘).detach();從DOM中把所有元素刪除
6.<p class="hello">hello</p>how are<p>you?</p>
$(‘p‘).detach(‘.hello‘);從DOM中把含有hello類的段落刪除
7.$(‘li‘).filter(‘.dd‘).css(‘color‘,‘red‘)
8.$(‘li‘).parent(‘‘).is(‘ol‘)若li裏為ol,則返回true

獲取位置