user2011714
user2011714

Reputation: 11

Remove an item from a checkbox list by its value using jQuery

I would like to remove an item from the checkbox list using its value

<input type="checkbox" name="chk" id="chk0" value ="Chicken">
$("#chk0:checkbox[value='Chicken']").parent().remove();

I am trying to remove the item but it is not working. I need some assistance.

Upvotes: 0

Views: 1293

Answers (1)

Eduardo Quintana
Eduardo Quintana

Reputation: 2388

If "#chk0" is your container. You will need to use

$("#chk0 :checkbox[value = 'Chicken']").parent().remove();

Note the space between the id and the :checkbox

Otherwise you will look for a checkbox with id ="chk0" instead of the checkbox inside of your container.

But if the #chk0 is the id for the input it will work fine..

Fiddle

Upvotes: 2

Related Questions