Reputation: 387
I have simple radio buttons. I have a .selected
class that turns the "+10", "0" and "X" labels red if you select one of them. This works:
However, if all of the above reside inside an angular.js- table, this does not work
I assume that the jQuery $(this).addClass
does not work properly and I'd need something else... Any ideas?
Upvotes: 0
Views: 399
Reputation: 40863
Another option that does not rely on jQuery
(getting in the habit of using jQuery in AngularJs can result in pain if not used correctly)
How about just some simple css:
input[type="radio"]:checked+label{ background-color: red; }
If the radio is checked the next label will be marked with a red background.
(btw, why are you using Angular 0.10.5?)
Upvotes: 1
Reputation: 58442
Not sure why your click isn't working but I found a workaround:
if you use the following jQuery below your main function it should work:
$(document).ready(function() {
$('#sites input:radio').addClass('input_hidden');
$(document).on('click', '#sites label', function() {
$(this).addClass('selected').siblings().removeClass('selected');
});
});
http://jsfiddle.net/peteng/KRMRU/25/
Upvotes: 1