Previous Message
Next Message

FIXED CSS background added by javascript not showing in IE

Sent by Tony Crockford on 2 November 2005 14:02


Tony Crockford wrote:

> so has anyone seen anything about not being able to set background
> images on elements with Javascript in IE?

it's to do with me using setAttribute ("class",classname");

IE doesn't like it.

This is the *proper* way to assign a class to an element with 
Javascript (AFAICT)

   for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
        anchor.getAttribute("rel") == "external")
	   anchor.className= "external";

  }

(that snippet will add class="external" to <a href="example.com" 
rel="external">  links)



-- 
http://wiki.workalone.co.uk
http://www.workalone.co.uk/ads.htm
http://www.xebit.net

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: