JSFiddle - React, Tailwind, and code Playground

HTML

Test here: <div id="test_holder"></div>

JavaScript

// create a container element
var cont = new Element('div', {
    'html':'Container html<br>'
});

// create a link, add to container
var link1 = new Element('a', {
    'href':'#',
    'html':'link1'
}).inject(cont);
// add event to link
link1.addEvent('click', function () {
    alert('link 1 click')
});

// add a new line to the container (this breaks link 1 reference)
cont.innerHTML += '<br>';

// create a second link
var link2 = new Element('a', {
    'href':'#',
    'html':'link2'
}).inject(cont);
// add an event to the second link
link2.addEvent('click', function () {
    alert('link 2 click')
});

// inject the whole mess into dom
cont.inject($('test_holder'));

console.log(link1);
console.log(link2);