[Javascript] Problems setting className

diego nunes dnunes at gmail.com
Fri Nov 11 10:46:39 CST 2005


    I built, some time ago, a "function kit" to help when I'm
DOMScripting. One of the functions wasn't so efficient, 'cause it had
four obrigatory parameters. I've made some changes, creating the new
"cE 2.0" (which stands for "Create Element"). This function creates an
element, and set the id, className and value (with DOM, obviously).
The function is...

function cE(tN, tID, tCN, tC) {
  // createElement 2.0 -- <str tagName>, [str id, str class] [, (str |
obj) content]
  if (!document.createElement) return false; var nE, tER;
nE=document.createElement(tN);
  if (arguments.length > 1) { if (arguments.length == 2) { tC=tID;
tID=tCN=''; } if (valorValido(tID)) { nE.id=tID; }
    if (valorValido(tCN)) { nE.className=tCN; } if (tC) {
nE.appendChild( (typeof(tC)=='string')?cTN(tC):tC ); }
  } return nE;
}

    It's working quite fine in all browsers, but Firefox. It simply
refuses to apply the "className" (the third parameter). Even in
Internet Explorer it works, and in Opera. Does anybody knows why the
hell it's behaving this way?!

  Amplexos.

--
diego nunes



More information about the Javascript mailing list