Monday, June 10, 2013

The Selected() Plugin

Part of the code I write requires a sort of radio button or toggle button functionality. The core ability is to be able to set an item as selected (or checked, active, clicked, etc.). I ran into this a lot and found myself writing the same simple code over and over again until I created the selected plugin.

Now i can simply write this with jQuery:
$("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:
https://github.com/jasonsavage2/jquery.selected

Let me know what you think.

No comments:

Post a Comment