0

Mootools code:

window.addEvent('domready', function() {
    var homeLink = $$('a.pathway');
    new Element('a', {'href': '/ru/produktsiya', 'html': 'Click me!'}).inject(homeLink, 'after');

});

Why didn't work?

Footniko
  • 2,682
  • 2
  • 27
  • 36

1 Answers1

2

$$ returns a collection of elements, which you cannot inject a single element after, of course.

window.addEvent('domready', function() {
  var homeLink = $$('a.pathway');
  new Element('a[href="/ru/produktsiya"][text="Click me!"]'}).inject(homeLink[0], 'after');
});

You can also use CSS selector logic to more easily create elements, as I've done above:

rgthree
  • 7,217
  • 17
  • 21