This is a follow up.
The answer that I was looking for was to set element.style.color=""
.
However when I tried to use this scipt in the markup of my ASP.NET web page, it didn't work in IE!?!
I debugged it in Visual Studio and though it was not throwing any errors, the set property seemed to be having no effect.
I therefore modified the code and used the cssText
property which I found in the debugger watch window in order to filter out certain values from the style by manipulating the csstext
string as this JSFIDDLE shows.
walk_the_DOM(wrapper, function(el) {
{
if (typeof el.style != "undefined") {
var attr = el.getAttribute("style");
if (attr != null) {
var attrs = attr.replace(/\s+/g, "").split(";");
attr = "";
for (var i = 0; i < attrs.length; i++) {
var propName = attrs[i].split(":")[0].toLowerCase();
if (propName != "" && propName != "background" && propName != "font-size" && propName != "color") {
attr += attrs[i] + "; "
};
};
if (attr == "")
el.removeAttribute("style");
else el.setAttribute("style", attr);
};
}
}
});