The Selected() jQuery Plugin

I find myself writing a lot of radio button/toggle button functionality. The core ability is to be able to set and unset an html element as selected (or checked, active, clicked, etc.). This functionality can be wrapped up nicely in a jQuery plugin I created called “selected()”.

Example:

$("a").selected(true);
var isSelected = $("a").selected();


Of course this led to being able to have a group of buttons with only one selected at a time:

$("a.tab").selectedGroup();


I have the plugin up on GitHub with a little more explanation and a demo: github.com/jasonsavage2/jquery.selected