Homer_J Homer_J - 1 year ago 81
jQuery Question

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
using the following, which works correctly:

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

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

Answer Source

You can use attribute equal selector

Live Demo


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download