<ul>
    <li id="MyOption1" class="MyClass_NotSelected" onclick="OptionToggle(this);" >Option 1</li>
    <li id="MyOption2" class="MyClass_NotSelected" onclick="OptionToggle(this);" >Option 2</li>
  </ul>

  <script>
    //----- TOGGLE OPTION -----
    function OptionToggle (CallingElement) {
    
      var CallingElementId = CallingElement.id;
      
      if (document.getElementById(CallingElementId).className == "MyClass_NotSelected")
      {
        document.getElementById(CallingElementId).className = "MyClass_Selected";
      }
      else
      {
        document.getElementById(CallingElementId).className = "MyClass_NotSelected";
      }
      
    }
  </script>
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *