Skip to content
Advertisement

How do I insert UL element to list

This is my jQuery script so far:

JavaScript

From that I have a list like this:

JavaScript

How do I add a <ul> right after <nav aria-label="Page navigation" id="alphanav"> and add </ul> right before </nav>?

I tried to use append but it just added <ul></ul> right after the first Nav

Advertisement

Answer

To fix this you can use the same methods of creating elements in jQuery as you already are. Simply create the ul in a jQuery object, append that to <nav> and then append your li to the ul you created. Something like the below. Note that I remove the datatable code as it wasn’t relevant to the issue.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement