Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery remove checkbox and associated label

I have the following:

<input type="checkbox" class="oDiv" id="Parent"  name="divcorp[]" value="Parent"/>
<label for="Parent">Parent</label>

I can remove the checkbox using the following, which works correctly:

$( "#Parent" ).remove();

However, how could I also remove the associated label for this checkbox?

like image 277
Homer_J Avatar asked Dec 13 '13 14:12

Homer_J


1 Answers

You can use attribute equal selector

Live Demo

$('label[for=Parent]').remove();

Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.

like image 181
Adil Avatar answered Sep 28 '22 09:09

Adil