老師講一個(gè)方法,我都在想這個(gè)是干嘛的呢?講完后我理解了老師的思路。。。
2017-03-23
document.getelementsByClassName() 是為了存到數(shù)組里,遍歷
2017-03-23
有時(shí)候沒(méi)有出效果,不一定是代碼錯(cuò)了,可能是jq版本不對(duì),1.8版本的outerHeight()就不行
2017-03-22
用屏幕大小window.screen.availWidth代替屏幕可用大小document.documentElement.clientWidth,就不會(huì)出現(xiàn)如果從小切換大的問(wèn)題吧
2017-03-22
function getByClass(clsName, parent){
var oParent=document.getElementById(parent)||document;
var oChild=oParent.getElementsByTagName('*');
var arr=[];
for(var i=0,l=oChild.length;i<l;i++){
if(oChild[i].className===clsName){
arr.push(oChild[i]);
}
}
return arr;
var oParent=document.getElementById(parent)||document;
var oChild=oParent.getElementsByTagName('*');
var arr=[];
for(var i=0,l=oChild.length;i<l;i++){
if(oChild[i].className===clsName){
arr.push(oChild[i]);
}
}
return arr;
2017-03-21
已采納回答 / 沒(méi)事兒多學(xué)習(xí)
var len1= getByClass('on','list');alert(len1.length);? // 結(jié)果等于2為正確var len2= getByClass('on');alert(len1.length);? // 結(jié)果等于3為正確給的模板錯(cuò)了,將這個(gè)代碼中第二處的len1.length改為len2.length就好了
2017-03-21
var p = document.getElementById(parent) || document;
return Array.from(p.getElementsByTagName('*'))
.filter(function(elem) {
return elem.className === 'on'
});
return Array.from(p.getElementsByTagName('*'))
.filter(function(elem) {
return elem.className === 'on'
});
2017-03-19
如果程序在打開(kāi)時(shí)沒(méi)有滾動(dòng)條,可以這樣解決,將原window.onscroll的執(zhí)行函數(shù)封裝成一個(gè)單獨(dú)函數(shù),然后在window.onload中添加一個(gè)立即執(zhí)行函數(shù):判斷圖片高度小于屏幕高度(即圖片未填充滿屏幕),則執(zhí)行封裝好的添加圖片的函數(shù)(去掉判斷條件),更新aPin,lastPinH,循環(huán)判斷,直到填充滿屏幕。
2017-03-19
最贊回答 / 韓云濤
你是不是沒(méi)有引用jQuery<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
2017-03-17
最新回答 / tawZ
if(i=16) 那條件永遠(yuǎn)滿足啊