I want to get some "regular" buttons to act like a group of radio buttons.
I found a jQueryUI plugin that does exactly what I want: http://jqueryui.com/demos/button/#radio
But I'd like to avoid adding another library to my project. Any idea how this could be done using pure HTML + javascript/jQuery ?
Thanks in advance
demo: http://jsfiddle.net/CXrgm/6
$('.button').click(function() {
$('.button').removeClass('active');
$(this).addClass('active');
});
where .button is your marker class for all buttons you need to include, and .active class whitch is indicate selected button.
to get the selected button use:
$('.button.active') // get attribute value, etc. Whatever you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With