Reputation: 513
Fiddle here: https://jsfiddle.net/0b4etshr/1/
How can I make the text of on each item_ k
change color ( toggleClass() ) when the input is checked?
$('item_').each(function(){
$(".iOScb").click(function(){
$('item_ k').toggleClass("active");
});
});
Do not work.
Upvotes: 0
Views: 64
Reputation: 8017
You can do something like this:
$("item_ [type='checkbox']").change(function() {
$("k", $(this).parents("item_")).toggleClass("active");
});
Basically, any time a checkbox contained in the <item_>
tag changes its state, the k
tag contained in <item_>
but in an level upper than the checkbox toggles the active
class.
Upvotes: 1