<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>json</title> </head> <body> <script> /* var data = ['张三',18,'男'] var person = {"name":"张三"} var person =[{ "name":"张三", "age":"18" },{ "name":"李四", "age":"12" }]*/ /* 获取滚动的头部距离 和左边距离 ** scroll().top scroll().left* ** */ function scroll(){ if(window.pageXOffset !==null){ return { top:window.pageYOffset, left:window.pageXOffset } }else if(document.compatMode==="CSS1Compat"){ return { top:document.documentElement.scrollTop, left:document.documentElement.scrollLeft } } return { top:document.body.scrollTop, left:document.body.scrollLeft } } window.onscroll = function (){ console.log(scroll().top) } </script> </body> </html>
每个你讨厌的现在,都有一个不努力的曾经