Reputation: 21
This script works in IE8 and Firefox, but it doesn't apply the "current" class or clear the "style" in IE7. Anyone know why? I replaced the real ID's and file paths with generic ones when I copied it here for security purposes.
var img = document.getElementById("imageID");
var div = document.getElementById("divID");
if (img.getAttribute('src') == "imagefilepath.gif") {
div.className = "current";
div.setAttribute('style', ' ' );
}
Upvotes: 1
Views: 201
Reputation: 22536
It appears that IE7 includes the entire path in the src
attribute, your condition isn't being met.
Upvotes: 1
Reputation: 76198
You can use this that'll work in all versions:
someId.setAttribute("className", "someClassName") ||
someId.setAttribute("class", "someClassName")
Upvotes: 0