Hm! It just tried it, it's true!
My idea was to try jQuery. As I thought, the equivalent solution with jQuery worked correctly:
$(fname).removeClass('txt');
$(spfname).removeClass('error-span');
$(fname).addClass('success');
$(spfname).addClass('success-span');
Please try it — jQuery is written with compatibility in mind. I did not look how jQuery works around the problem in JavaScript code, but it certainly works the same way on the Browsers I tested: Mozilla Seamonkey vs. IE vs. Google Chrome.
[EDIT]
I don't see initialization of the variables
fname
and
spfname
in your code but assumed they are objects correctly representing DOM elements, so they could serve as valid parameters to the jQuery
$()
function, which can also accept different types of parameters (selectors using IDs, classes, XPath queries and the combinations of those) and return jQuery wrapper objects representing a set of DOM elements, with a number of functions.
—SA