palak sharma palak sharma - 1 year ago 72
jQuery Question

how to add a line break or <br/> after every list item using jquery?

I have 100 list items and to make it look nicer i want to add a line break tag after the end of every list item. So how can I do it using javascript or jquery?

Answer Source

Here is a simple solution, I used insertAfter (jquery) to insert <br/> after each li


<script src=""></script>
  <li>ITEM 1</li>  
  <li>ITEM 2</li>  
  <li>ITEM 3</li>  
  <li>ITEM 4</li>  

But, you don't need JavaScript for doing this, you could do this easily by CSS

ul > li{
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
  <li>Item 5</li>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download