3

For some reason I am having an issue where .prepend() is occurring twice.

My code is as follows:

<ul id="menu">
    <li id="menu-item-1">Menu One</li>
    <li id="menu-item-2">Menu Two</li>
    <li id="menu-item-3">Menu Three</li>
</ul>

$(document).ready(function() {

    var html = '<li id="menu-item-0">Menu Zero</li>';
    $('#menu').prepend(html);

});

The fiddle, https://jsfiddle.net/2Ljf9qn8/, is working properly.

Is there any known reason why this would produce the following?

  • Menu Zero
  • Menu Zero
  • Menu One
  • Menu Two
  • Menu Three

Any help is greatly appreciated.

FYI: I did remove the prepend outside of doc ready, just in case the page was loading twice, but still no luck.

Matthew Woodard
  • 754
  • 2
  • 10
  • 26

0 Answers0