Skip to content
Advertisement

After executing a function style is no more displayed

I need to display some boxes, however when I activate the function to order them the padding between each box desappears. Do you know how to fix this?

JavaScript

There is also some css code for the style of the list. But when i execute the function mia_posizione the padding between the boxes is canceled and they are displayed all too close to each other

JavaScript

Advertisement

Answer

In your original HTML you had <br> nodes between your <li> elements providing some vertical distance. After sorting the list items you then append()-ed the <li> directly one after the other – without the <br> nodes between them into the <ul> container.

In the following snippet I removed the <br> nodes and introduced some spacing between the <li> elements with the CSS directive #list li {margin-bottom:2em}:

JavaScript
JavaScript
JavaScript
Advertisement