JSFiddle - React, Tailwind, and code Playground

by Pointy

HTML

<div style='padding: 50px 0px 10px 5px'>
  <input type='radio' name='diet' id='vegan' value='vegan'>Vegan
  <input type='radio' name='diet' id='veggie' value='veggie'>Vegetarian
  <input type='radio' name='diet' id='omni' value='omni'>Omnivore
</div>

<div class='togglefrog menu' data-toggler='vegan'>
  <input type='radio' name='meal' value='sprouts'>
  Sprout salad with chickpea chips<br>
  <input type='radio' name='meal' value='tofu'>
  Toasted pressed tofu with soy-garlic gravy with 
  sweet/sour green beans<br>
  <input type='radio' name='meal' value='beanburger'>
  Black bean burger on spelt-quinoa bun with homemade 
  ketchup and sweet potato fries
</div>

<div class='togglefrog menu' data-toggler='veggie'>
  <input type='radio' name='meal' value='grill'>
  Grilled cheddar with tomato on spelt-quinoa bread 
  with sweet potato fries<br>
  <input type='radio' name='meal' value='taco'>
  Seitan and pepper stir-fry and aged Monterrey Jack 
  in whole-wheat tortillas with tomato-parsley salad<br>
  <input type='radio' name='meal' value='soup'>
  Creamy broccoli cheddar soup with pumpkin seed crackers
</div>

<div class='togglefrog menu' data-toggler='omni'>
  <input type='radio' name='meal' value='meatburger'>
  Angus beef burger on spelt-quinoa bun with homemade 
  ketchup and sweet potato fries<br>
  <input type='radio' name='meal' value='salmon'>
  Alaskan salmon steak with chipotle glaze and aromatic 
  brown rice<br>
  <input type='radio' name='meal' value='chicken'>
  Chardonnay-poached chicken breast with buttered peas 
  and aromatic brown rice
</div>

CSS

div.menu { position: absolute; display: none; }
div.menu.toggled { display: block; }

JavaScript

/*
Togglefrog.js
Copyright 2011 Mike McNally - All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

(function($, window, undefined) {

  var
    rbang = /^!/
  , rtrim = /^\s*(\S*)\s*$/
  , pageOptions = {}
  , CHECKED = 'checked'
  , WAS_CHECKED = 'togglefrog-waschecked'
  , MARKER = 'togglefrog-' + new Date().getTime()
  , MARKER_SELECTOR = '.' + MARKER
  , TOGGLE_STATUS = 'togglefrog-status'
  , TOGGLERS = 'togglefrog-togglers'
  , OPTIONS = 'togglefrog-options'
  ;

  function isUndef(v) {
    return typeof v === 'undefined';
  }

  // Fix option tags without "id" values
  function createOptionIds() {
    return this.each(function() {
      var sel = this, $sel = $(this);
      if (sel.tagName.toUpperCase === 'SELECT' && sel.id) {
        $sel.find('option').each(function() {
          if (this.id) return; // already has an id
          // we're not going to check for pre-existing id values, so 
          // it's a good idea to avoid the situation on your pages :-)
          this.id...