Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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