I'm facing a challenge
$('input[type=radio][name="voucher_type"]').on('change', function() {
//doing something here
});
So, when a radio button is clicked, actions are taken. The radio button sits inside a styled div that acts as a large button with a background image, and so on.
The issue arises when users click the image and expect the button to be clicked. Using a label to check the radio is not an option for me, so I attempted this code snippet:
$('div.voucher_box').click(function(){
$(this).children('input').attr("checked", "checked");
$(this).closest("input").trigger('click');
});
I was anticipating that clicking on the div with the voucher_box class would trigger a click/change event on the radio button and execute all the relevant code associated with radio changes.
Is there anyone who can pinpoint what's going wrong? Appreciate it.