看板 Web_Design 關於我們 聯絡資訊
我用了 getElementsByClassName 的函數來找出所有 memhead1 的 object 可是 document.getElementsByClassName("memhead1") 有東西 document.getElementsByClassName("memhead1").length 卻是 0 ? 為什麼會這樣呢? Source: https://github.com/BruceChen034020/20180510BugDemo 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 120.126.66.25 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1526023777.A.95C.html
Kenqr: js執行的時候 body都還沒載入 所以抓不到 05/11 15:45
Bruce003: 要怎麼先載入 body 再執行 js ? 05/11 16:18
jhnny97: <body onload="somefunction();"> 05/11 17:02
nottt: 最簡單的作法,把javascript放到html內容之後 05/11 22:31
nottt: 這樣同時也可以增加網頁出現畫面的速度(總速度不變) 05/11 22:32
nottt: 上面放錯 https://codepen.io/not0000/pen/pVVPRy 05/11 22:33
ymcheung: 缺了 dom ready 的東西? 05/11 23:11
Bruce003: 解決了,謝謝大家 05/18 12:45