I am working on a logic for checkboxes. Where if the checkbox is unticked, It hides the created list item. An example of this is on jsFiddle I have the tick logic working, But what I’d like is the “Untick” logic to work.
I have given each li item a class, So basically looking to pair the two together to remove the list item. But just not having any luck.
Can anyone help me on extending this logic so that I show / hide the unticked li item, Otherwise I’m just left with a never ending list of items.
Thanks
1) Use the
changeevent for listening to checkboxes. If you useclick, you ignore any state changes that come from keyboard interaction.2) Your current “if not checked” code is creating a NEW
liand removing that (before it’s even entered the DOM) – presumably not what you meant.I’ve assumed you meant to remove CURRENT
lis that have a class equal to thenameattribute of the changed checkbox. See updated Fiddle:http://jsfiddle.net/qYtXX/9/