TypeError: Cannot red property 'style' of null 错误解决

错误信息如下:

JSP代码如下:

<c:if test ="${not empty excelErrors}">
    <div id="excelErrorDiv" class="acxiom-content-container closed rounded vpad top-buffer" style="width:90%;margin-left:5%;">
        <div class="acxiom-table top-buffer" style="display:block;width:80%;margin:10% 0% 10% 10%;">
        <div id="handlingExcelError" class="row-fluid" style="font-size:20px; display: block;" >
                <span style="font-size:20px;">
                    <font color="#B85F1B"><strong>Warning  !!</strong>  Importing file has some errors as below:</font>
                </span>
        </div>  

            <div class="row-fluid" style="font-size:20px; padding-top:50px;">
                <div align="center">
             <c:forEach var="excelError" items="${excelErrors}">
                <table>
                 <tr>
                 <td>${excelError} </td>
                 </tr>  

                </table>
                </c:forEach>   

                </div>
            </div>  

        </div>
    </div>
    </c:if>  

因为有<c:if >的判断,当excelErrors为空的时候,div不会被加载。

所以js里面的这段话执行就报错了

document.getElementById(‘excelErrorDiv‘).style.display = ‘block‘;  

解决办法:

js里面修改为:

if($("#excelErrorDiv")){
            $("#excelErrorDiv").hide();
        }  

TypeError: Cannot red property 'style' of null 错误解决

时间: 2024-08-10 19:54:19

TypeError: Cannot red property 'style' of null 错误解决的相关文章

Uncaught TypeError: Cannot read property ‘style‘

js在浏览器报出如下错误(chrome中):Uncaught TypeError: Cannot read property 'style' of null 浏览器如果报出如下错误(chrome中):Uncaught TypeError: Cannot read property 'style' of null  请问这错误具体是什么意思?(您需要掌握JS常见错误的处理和常见英文报错的意思) 调用style属性的object是空的,一般是元素获取出错造成的 比如你想用 document.getE

Uncaught TypeError: Cannot set property &#39;innerHTML&#39; of null

学习Chrome插件时,要在弹出页面中显示当前时间,结果怎样也显示不出来 看了 http://www.cnblogs.com/mfryf/p/3701801.html 这篇文章后感悟颇深 通过调试发现在js中的一段代码没有执行到,报以下错误 Uncaught TypeError: Cannot set property 'innerHTML' of null  然后查询该错误原因,结果是因为js引用放在了页面的头部,在修改 innerHTML 属性时找不到该属性,因为需要修改一个html标签中的

Uncaught TypeError: Cannot read property &#39;ownerDocument&#39; of null

/********************************************************************* * Uncaught TypeError: Cannot read property 'ownerDocument' of null * 说明: * 尝试将SVG文件内容通过JS Ajax加载,然后动态插入div中,报这个错误, * 解决办法,直接将svg后缀改成html,就可以了. * * 2017-8-25 深圳 龙华樟坑村 曾剑锋 *********

eslint Cannot read property &#39;range&#39; of null错误

手动添加的配置,2个项目OK,还个项目 运行报错 Cannot read property 'range' of null TypeError: Cannot read property 'range' of null at SourceCode.getTokenBefore (/Users/jason/my-project/node_modules/eslint/lib/token-store/index.js:303:17) at checkSpacingBefore (/Users/jas

Three.js three.js Uncaught TypeError: Cannot read property &#39;getExtension&#39; of null

在调试Three.js执行加载幕布的时候,突然爆出这个错误three.js Uncaught TypeError: Cannot read property 'getExtension' of null,查询了半天也没找到结果 最后突然想到是不是浏览器的设置问题,检查了一下WebGL,果然重新安装浏览器之后没有开启,正常开启之后,显示正常 留痕MARK一下 PS:可以直接在百度上搜索浏览器的WebGL的开启方式 :) Three.js three.js Uncaught TypeError: C

[Vue warn]: Error in render: &quot;TypeError: Cannot read property &#39;length&#39; of null&quot;

[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null" 看到ta,总是能让人勾起心中的躁动,呼吸变得急促,嘴唇有些干涩,眼神瞬间专注,思想更是达到了忘我的境界,因为老板说,今天bug不改完就不能去吃晚饭哇! 看到这样的报错是最让人一头雾水的,渲染出错,要定位到是什么标签引起的,标签为什么引发这样的报错,错误代码定位可以用排除法,把错误的代码注释掉,如果不报错了,那就是注释的代码出了问

eslint Cannot read property &#39;range&#39; of null错误( Quasar Doc )$ quasar dev 出错

手动添加的配置,2个项目OK,还个项目 运行报错 Cannot read property 'range' of null TypeError: Cannot read property 'range' of null at SourceCode.getTokenBefore (/Users/jason/my-project/node_modules/eslint/lib/token-store/index.js:303:17) at checkSpacingBefore (/Users/jas

Uncaught TypeError: Cannot set property &#39;f7View&#39; of undefined 错误原因

// 添加视图var mainView = myApp.addView('.view-main', { // 因为我们要用动态的导航栏,我们需要使它的这一观点: dynamicNavbar: true});// 添加视图var mainView4 = myApp.addView('.view-main4', { // 因为我们要用动态的导航栏,我们需要使它的这一观点: dynamicNavbar: true}); 错误原因,多了一个添加视图,删除一个就好 Uncaught TypeError:

vue报错 Uncaught TypeError: Cannot read property ‘children ’ of null

Uncaught TypeError: Cannot read property 'children ' of null ratings未渲染完毕,就跳走goods了,取消默认跳转,即可