Reputation: 217
In IE below line is working . popup is a div element.
popup.all("submenu").innerHTML = "";
But in other browsers below error is coming
popup.all is not a function.
Is there any alternative for all function in other browsers.
Please suggest me. Thanks.
Upvotes: 0
Views: 595
Reputation: 1341
try this:
var popup=document.getElementById('popup');
for (i in popup.childNodes) {
if (popup.childNodes[i].nodeType == 1) {
popup.childNodes[i].innerHTML = '';
}
}
Upvotes: 0
Reputation: 38345
Use document.getElementById(elementName).innerHTML = whatever;
instead.
Upvotes: 0
Reputation: 146588
In all browsers (including Internet Explorer) you are expected to find items by their location in the DOM tree (I'm assuming it's a DOM node given the .innerHTML
property). You can use, for instance, document.getElementById() and document.getElementsByTagName(). Of course, you can always store references to nodes in regular variables.
Upvotes: 1
Reputation: 3758
All method is not supported by most browsers. Except IE ofcourse. Test for document.getElementById if this is false then use the "all" method.
Upvotes: 1