Hi, I have this piece of javascript inserted after a list of <li></li> tags it's supposed to work it's magic on. It should find the list tags with no content and delete them and then remove all except the first 5 instances of <li></li>
Link to jQuery is in the <head> and the list is generated by a piece of PHP - which seems to work fine. The list pops up but it's way too long and filled with empty <li>'s
I've stared at it for too long and can't see what I'm missing. I'm very rusty at JS, so it might be something blatantly obvious hehe
Any help is much appreciated
Link to jQuery is in the <head> and the list is generated by a piece of PHP - which seems to work fine. The list pops up but it's way too long and filled with empty <li>'s
Code:
<div class="facebook"> <h2>Facebook</h2> <ul> <li>1</li> <!-- example text--> <li>2</li> <li></li> <li>4</li> <li>5</li> <li></li> <li>7</li> <li>8</li> </ul> <script type="text/javascript"> <!-- $(document).ready(function() { $('.facebook ul').find('li').each( function(){ if($(this).html().length == 0){ $(this).remove(); } }); $('.facebook ul').find('li').slice(5).remove(); }); --> </script> </div>
Any help is much appreciated

Comment