最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "Cannot read property 'xxx' of null" - Stack Overflow

programmeradmin6浏览0评论

I've got a document fragment with children that I want to loop over (when possible). This is causing an error "Cannot read property 'xxx' of null".

How do I test if this will be the case?

I've got a document fragment with children that I want to loop over (when possible). This is causing an error "Cannot read property 'xxx' of null".

How do I test if this will be the case?

Share Improve this question asked Apr 26, 2010 at 7:54 MatrymMatrym 17.1k35 gold badges99 silver badges141 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You may want to do the following:

if ((documentFragment !== null) && documentFragment.hasOwnProperty('xxx')) {
    // handle property xxx of documentFragment as required
}
发布评论

评论列表(0)

  1. 暂无评论