Using jQuery UI I have two radio buttons, Approve/Reject, which I would like to style independantly, so when ‘Approve’ is selected, it will be blue, and when ‘Reject’ is selected, it will be red:



Apologies for my terrible red button mockup 🙂 Hopefully this will give you an idea of what I’m after. I’ve tried changing the class of both buttons/labels, but this isn’t then reflected onto the jQuery-UI overlay.
Here’s my current code that is generating the buttons, and also displaying a tick or a cross depending on the selection:
$('.approvedToggle').buttonset();
$('input:radio').click(function() {
if($(this).val() === 'approve') {
$(this).parent('div').children(".tick").show();
$(this).parent('div').children(".cross").hide();
} else {
$(this).parent('div').children(".tick").hide();
$(this).parent('div').children(".cross").show();
}
});
Any help would be much appreciated – thanks!
What you need to do is override the jQuery UI default styling.
Here’s what the documentation states:
So basically, what you can do, is something like this:
HTML:
CSS (Important! This styling MUST be declared AFTER the jQuery UI CSS file):
jQuery:
Output:
See the working jsFiddle demo