krrr25
krrr25

Reputation: 679

Remove span from a html output

I want to remove a span tag from a html output.

Say like i have a variable template which holds a html output.

<li id="GRP_1" data-role="list-divider">Group 1<span id="121" onclick="deleteGroup(this.id);" class="ui-icon ui-icon-delete ui-icon-shadow li-divider-icon-right">&nbsp;</span></li>

In the above html output i want to remove/hide the span tag. If possible give me a solution for both hide & remove that span tag. Find the fiddle example here

Upvotes: 0

Views: 282

Answers (4)

NewRehtse
NewRehtse

Reputation: 338

Also:

$('#GRP_1').find('span').hide();
$('#GRP_1').find('span').show();

Upvotes: 0

Marius
Marius

Reputation: 1073

You could do it in many different ways.

By id:

$('#121').hide(); or $('#121').remove();

By html element:

$('span').hide(); or $('span').remove();

And by class:

$('ui-icon.ui-icon-delete.ui-icon-shadow.li-divider-icon-right').hide();

or

$('ui-icon.ui-icon-delete.ui-icon-shadow.li-divider-icon-right').remove();

Upvotes: 1

Koenyn
Koenyn

Reputation: 704

$('li span').remove();

$('li span').hide();

Upvotes: 0

Anton
Anton

Reputation: 32581

$('#121').hide();

$('#121').remove();

I recommend you to change the id from numbers to letters or letters + numbers. Or add a unique class to your span.

Upvotes: 1

Related Questions