user123_456
user123_456

Reputation: 5795

delete html tag with jquery using attribute name

I want to delete label tag with everything inside.

$('label.checkbox.inline input:radio[name="'+data.name+'_'+ data.hidden+'"]').remove();

And this is html..

<label class="checkbox inline"><input type="radio" name="f05_55" value="2/">yes<br></label>

Problem that I have is that only an input element is deleted and I want to remove everything.

How can I do that?

Upvotes: 0

Views: 103

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382092

You're selecting the input instead of the label.

You could do this :

$('label.checkbox.inline input:radio[name="'+data.name+'_'+ data.hidden+'"]')
.parent().remove();

or this :

$('label.checkbox.inline:has(input:radio[name="'+data.name+'_'+ data.hidden+'"])')
.remove();

But note that you shouldn't put the input inside the label.

Upvotes: 2

Related Questions