I am writing a custom survey view, which replaces check boxes with "buttons" which are just regions rendered with CSS.
I am trying to trigger an event when a region is clicked. When the region outside of the text is clicked, the event is triggered, but when the text is clicked, nothing happens. I am very new to jQuery (started several days ago). Am I missing something completely obvious? Thanks
$('.checkbox-select').click(function () {
var checked_length = $(this).has(".checked").length;
if (checked_length == 0) {
$(this).find('[type=checkbox]').addClass('checked');
$(this).find('[type=checkbox]').prop('checked', true);
$(this).find('label').css({
"font-style": "italic"
});
$(this).css("background-color", "#6CCACD");
} else {
$(this).find('[type=checkbox]').removeClass('checked');
$(this).find('[type=checkbox]').prop('checked', false);
$(this).css("background-color", "#67517A");
$(this).find('label').css({
"font-style": ""
});
}
});
Here is the problem reproduced: http://jsfiddle.net/m8r4xp6b/