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:
Pleas开发者_JS百科e help me to rectify the issue
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.
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;
Make sure that your <script>
is after the element #totaldisplay
(also that the id is unique on your page).
精彩评论