• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Jquery - .remove() bug

I'm trying to remove empty UL tags using Jquery below:

$("ul").each(function(){
     if ($(this).find("li").length == 0) {
     $(this).remove();
     // $(this).css("border","20px solid red");
     }
});

The strange thing is the $(this).remove(); doesn't work, whereas $(this).css("border","20px solid red"); in the code above works!

Are there any known bugs with .remove() ?  
0
jeremyll
Asked:
jeremyll
  • 2
1 Solution
 
ansudhindraCommented:
your code is working..
I dont see any bugs and is doing what it has to do..

BR-Sudhindra-www.clicksperday.com
0
 
leakim971PluritechnicianCommented:
please provide the html
0
 
ansudhindraCommented:
here is the working one..

http://jsfiddle.net/Sudhindra/6hybe/

Please post the complete code (html)...

BR- Sudhindra-www.clicksperday.com
0
 
ProculopsisCommented:

// Not quite what you what but try this instead:

$(this).css( {display: "none"} );
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now