I don’t know what the specific name to this kind of form controller is (if there even is one), but basically I want to change radio elements like so;
<input type="radio" name="size" value="S" id="size_S" />
<label for="size_S">S</label>
<input type="radio" name="size" value="M" id="size_M" />
<label for="size_M">M</label>
<input type="radio" name="size" value="L" id="size_L" />
<label for="size_L">L</label>
…into stylized links, the checked of which has a special class. For an example, I’d list the size selection element on Macys.com.
How can I turn the radios into these kinds of box links? Is there a library or plug-in that already does this?
I can modify the DOM, but the elements need to be radio buttons for the convenience of non-JS users.
You can pretty much reuse the standard form elements. With js enabled, hide the radio buttons, style the labels, and bind a
clickevent to add theactive/selectedclass. Clicking a label will still select the underlying radiobutton.Example jsFiddle: http://jsfiddle.net/Y6BzY/
JS
CSS