I have an unordered list that I have reversed with javascript. My script works but the list is duplicated. The page renders with the original list plus the output of twhat my js is doing. How can I make it only render once? Should I rewrite with jQuery and use .detach() ? Below is my code:

```
var navList = $('ul.menu');
var navListItems = list.children('li');
navlist.append(navListItems.get().reverse());

```