Reddirt
Reddirt

Reputation: 5953

jquery remove not working

I'm trying to remove some li lines of html.

This is the html:

HTML

This is the jquery I'm trying to use:

$("li").remove(":contains('undefined')");

Thanks for the help!

Upvotes: 0

Views: 211

Answers (3)

adeneo
adeneo

Reputation: 318182

I'd do it this way :

$('li').filter(function() {
    return $(this).find('span').text().indexOf('undefined') != -1;
}).remove();

Upvotes: 1

user1386320
user1386320

Reputation:

Try:

$("li span:contains('undefined')").remove();

It works in my head :)


EDIT This will remove the LI:

$("li span:contains('undefined')").parent().parent().remove();

Upvotes: 0

DarkAjax
DarkAjax

Reputation: 16223

You can try:

$("li:contains('undefined')").remove();

Upvotes: 2

Related Questions