document.getElementById('grand_total_display').innerHTML = “Total is : $”+variable; is displaying error in IE6 and IE7

送分小仙女□ 提交于 2019-12-13 08:31:27

问题


document.getElementById('grand_total_display).innerHTML = "Total is : $"+variable; is displaying error in IE6 and IE7

I have an <li>with id as grand_total_display with some text displayed in it.

<li class="bannerprice" id="grand_total_display">TOTAL PRICE : $0</li>

I am executing a jjavascript function to insert some other value into it.. but I am displayed with the error as given below:

Please help me to rectify the issue


回答1:


Apparently there's no element in the DOM with 'totaldisplay' as its id, or, as galambalazs suggests, you might have multiple elements with the same id.

With IE7 you can use "Internet Explorer Developer Toolbar" and "Web Development Helper" plugin, to find the problem.




回答2:


You have the wrong ID:

variable = "howdy";
document.getElementById('grand_total_display').innerHTML = "Total is : $"+variable;

instead of

variable = "howdy";
document.getElementById('totaldisplay').innerHTML = "Total is : $"+variable;



回答3:


Make sure that your <script> is after the element #totaldisplay (also that the id is unique on your page).



来源:https://stackoverflow.com/questions/3890659/document-getelementbyidgrand-total-display-innerhtml-total-is-variab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!