function $(className) { var newClassName = className.split(" "); if (newClassName.length > 1) { var father = newClassName[newClassName.length - 2]; var childrenList = document.querySelector(father).children; var arr = Array.from(childrenList).filter(function (el){ if ( el.className.indexOf( (newClassName[newClassName.length-1]).replace(".", "") ) > -1 || el.tagName.toLowerCase() == newClassName[newClassName.length-1] ) { return el; } }); if (arr.length > 1) { return document.querySelectorAll(className) } else if (arr.length == 1){ return document.querySelector(className) } else { throw new Error(`${className} 不存在,请检查`) } } else { return document.querySelector(newClassName); } } function scroll(callback) { $("body").onscroll = () => { let scrollTop = document.documentElement.scrollTop || document.body.scrollTop; let clientHeight = document.documentElement.clientHeight || document.body.clientHeight; let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; if(scrollHeight > clientHeight && scrollTop + clientHeight === scrollHeight) { callback() } } } function query(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if(r!=null)return unescape(r[2]); return null; }