課程
/前端開發(fā)
/JavaScript
/瀑布流布局
問題出在哪里
2017-04-09
源自:瀑布流布局 2-3
正在回答
我也是~
正在睡覺
慕粉3596818 提問者 回復 正在睡覺
慕粉3596818 提問者
隊友殺手 回復 正在睡覺
qq_終究落下_04415476 回復 慕粉3596818 提問者
把<scirpt>放到<body>的最下面,頁面加載完再進行js。這個是因為沒有找到元素,console.log(oparent)為null
你是怎么解決的啊
window.onload?=?function?()?{ waterfall("main","pin"); } function?waterfall(?parent,?pin?)?{ var?oParent?=?document.getElementById(parent); var?oBoxs?=?getByClass(oParent,"pin"); //?var?oBoxs?=?oParent.getElementsByClassName("pin"); var?oBoxw?=?oBoxs[0].offsetWidth; var?cols?=?Math.floor(document.documentElement.clientWidth?/?oBoxw); oParent.style.cssText?=?"width:"?+?oBoxw*cols?+?"px;?margin:0?auto;"; } function?getByClass?(?parent,?cls?)?{ //var?oParent?=?document.getElementById(parent); var oElements?=?parent.getElementsByTagName("*"); var?boxArr?=?new?Array(); for(var?i?=?0;?i?<?oElements.length;?i++)?{ if(oElements[i].className?==?cls){ boxArr.push(oElements[i]); } } return?boxArr; }
舉報
瀑布流布局是網(wǎng)站比較流行的一種布局方式,教你實現(xiàn)三大方式
1 回答mian.js:18 Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
5 回答Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined
1 回答一直顯示這個Cannot read property 'style' of null
1 回答出現(xiàn)Cannot read property 'style' of undefined錯誤
1 回答Uncaught TypeError: Cannot read property 'offsetHeight' of undefined?求指教?。?!
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2017-04-09
我也是~
2017-11-22
把<scirpt>放到<body>的最下面,頁面加載完再進行js。這個是因為沒有找到元素,console.log(oparent)為null
2017-07-23
你是怎么解決的啊
2017-04-09