Thomas Meinike: createElement + setAttribute

Beitrag lesen

Hallo,

var Elm = document.createElement('span');

dann werden diesem zwei Attribute zugewiesen:

Elm.setAttribute("class", 'GapSpan');
Elm.setAttribute("onclick", 'DoSthg()');

In Mozilla funktioniert alles bestens nur im IE nicht.

Probiere es so:

Elm.className='GapSpan';

Elm.setAttribute("onclick", 'DoSthg()', true);
oder
Elm.onclick=DoSthg; // ohne ()!
oder
Elm.onclick=function(){DoSthg()};

MfG, Thomas

--
SVG - Learning By Coding
http://svglbc.datenverdrahten.de/