0

In page I have that code:

<ul>
<li>Name 1</li>
<li>Name 2</li>
<li>Name 3</li>
<li>Name 4</li>
<li id="beforeInsert"></li>
</ul>

And I try to inject some of these code:

<li>Name 5</li>
<li>Name 6</li>
<li>Name 7</li>

before <li id="beforeInsert"></li> element whith that function:

html.inject("beforeInsert", "before");

But this function just add a first <li> element from my second list, in <ul> block. What I do wrong?

Donatas Veikutis
  • 974
  • 2
  • 15
  • 36

1 Answers1

0

The inject function works on mootools dom elements. so you can do something like this:

var el_before = document.id('beforeInsert');
[5,6,7].each(function(num){
   var li = new Element('li').set('html','Name ' + num);
   li.inject(el_before,'before');
});

jsfiddle

Adidi
  • 5,097
  • 4
  • 23
  • 30