[Javascript] removeAttribute issue IE7

Matt Warden mwarden at gmail.com
Mon May 3 15:38:16 CDT 2010


On Mon, Apr 19, 2010 at 1:11 PM, jeffrey morin <rufus2021 at gmail.com> wrote:
> Hey everyone,
>
> I am editing a script that is having issues in IE7 and can't figure this
> out. A radio button has an onclick event handler and when it is fired it
> calls a script that removes a class name from a div element. For whatever
> reason it doesn't work for IE7 though.
>
> It is very straight forward and says just this.
>
> var div = document.getElementById('div')
> div.removeAttribute('class')
>
> I threw an alert in there to give the class name and Ie returns it as null.
> The weird thing is that when I just use div.className = ' ' it works just
> fine. Does anyone know what is going on here? I am stumped.

IE generally complains when you attempt to modify attributes using the
setAttribute-style methods when the attributes are available in the
object model. Stick to using object.className

-- 
Matt Warden
Cincinnati, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the Javascript mailing list