获取元素到body的距离: <script> function offsetDis(obj) { var l = 0, t = 0; while(obj) { l = l + obj.offsetLeft + obj.clientLeft; t = t + obj.offsetTop + obj.clientTop; obj = obj.offsetParent; } return {left: l, top: t}; } </script>
a. onscroll事件 scroll是css样式中overflow的一个值,意思是显示滚动条;当一个元素的实际高度超过他的最大高度是,只要设置了overflow为scroll b. $(..).scrollTop() 可以获取滚轮高度,如果填入参数则可以把屏幕移动到参数的滚轮位置 c. $(..).scrollTop(10) =>$(..).scrollLeft(10) d. 如何获取某个标签距离顶部高度 $(..).offset() 获取当前标签距离文档顶部高度 $(..).height(
As it turns out, there is a string method named find that is remarkably similar to the function we wrote: >>> word = 'banana' >>> index = word.find('a') >>> index In this example, we invoke find on word and pass the letter we ar
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 →