0

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.

2
  • Why are you spacing everything out? value="Chicken" is much easier to read than value = "Chicken". Commented Mar 10, 2014 at 15:42
  • works without those spaces: jsfiddle.net/JY4js Commented Mar 10, 2014 at 15:46

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

#chk0 is the ID of the checkbox. The markup is already within the question. Furthermore, this should have been a comment.
I answered before the question was edited and I saw only the value of the checkbox i didn't realized that the id was for the checkbox because it was plain text , that's why i put "If "#chk0" is your container. You will need to use" But thanks I will be more careful the next time
Thanks everyone. I figured it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.