Search code examples
javascriptmootools

Mootools new Element does not work


new Element does not work. Someone has any clue why? css:

#tileNode {
position:absolute;
width:100px;
height:100px;
background-color:red;
}

js:

window.addEvent('domready', function() {
var newElement = new Element('div',{id:"tileNode"});
newElement.inject($$('div#tileNode'));
alert($$('#tileNode').get('id'));
});

Alerting #root works fine so it exists... creating that tileNode element does not work alerting it also does not work :/

Kind regards!


Solution

  • you can also use this to inject:

    newElement.inject($$('div#tileNode')[0]);