javascript - 某元素的子元素无法被js获取
PHP中文网
PHP中文网 2017-04-11 12:36:55
0
0
601

把chrome的安全策略关掉之后,在动漫之家的网页加载前载入外被文件 内容如下

document.addEventListener('DOMContentLoaded', () => { console.log(document.querySelector('#center_box')); console.log(document.querySelector('#center_box > img')); pic = document.querySelector('#center_box > img'); if (pic.complete) { downloadPic(); window.stop(); return; } pic.addEventListener('load', downloadPic); });

得到的结果是

null

结果为什么会是null,而且对center_box调用childnodecount()得到的结果是0

PHP中文网
PHP中文网

认证高级PHP讲师

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!