码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-06-05 12:23:32      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:js   jsp   typeerror   

错误信息如下:
<img src="http://img.blog.csdn.net/20150605110940250?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2huZGF0YQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
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('<pre name="code" class="html">excelErrorDiv
‘).style.display = ‘none‘;


<strong>解决办法:</strong>
js里面修改为:
<span style="white-space:pre">	</span>if($("#excelErrorDiv")){
<span style="white-space:pre">			</span>$("#excelErrorDiv").hide();
<span style="white-space:pre">	</span>}

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

标签:js   jsp   typeerror   

原文地址:http://blog.csdn.net/chndata/article/details/46374071

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!