getAttribute() in IE

E

emma.sax

Hi

I have the following code which is working in Firefox:

function showOptions() {
if(!document.getElementById) return false;
if(!document.getElementsByTagName) return false;
var lnks = document.getElementsByTagName("a");
for(var i=0; i<lnks.length; i++) {
alert(lnks.getAttribute("class"));
if(lnks.getAttribute("class") == "toggle") {
lnks.onclick = function() {
var options = document.getElementById("multiretailers");
options.style.display="block";
}
}
}
}

I understand that IE doesn't like he getAttribute() method and is
returning null for the class name.

What are the work arounds for this?

Thanks

M
 
D

David Dorward

if(lnks.getAttribute("class") == "toggle") {

I understand that IE doesn't like he getAttribute() method and is
returning null for the class name.

I believe IE will accept getAttribute("className") - but its probably
easier just to use lnks.className.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top