Alex Rivera | Logout

getElementsByName in IE7

Asked 2008-11-10T18:26:23.983
17

I have some code doing this :

 var changes = document.getElementsByName(from);
 for (var c=0; c<changes.length; c++) {
   var ch = changes[c];
   var current = new String(ch.innerHTML);
   etc.
 }

This works fine in FF and Chrome but not in IE7. Presumably because getElementsByName isn't working in IE. What's the best workaround?

Edit
Report

2 Answers

2

It's not very common to find elements using the NAME property. I would recommend switching to the ID property.

You can however find elements with a specific name using jQuery:

 $("*[name='whatevernameYouWant']");

this will return all elements with the given name.

answered 2008-11-10T18:57:53.013
1

Just another DOM bug in IE:

Bug 1: Click here

Bug 2: Click here

answered 2008-11-10T22:54:09.340

Your Answer