JavaScript show and hide UL list

From , 5 Years ago, written in JavaScript, viewed 155 times.
URL https://pastebin.vip/view/62e09734
  1. <ul id="rightNav">
  2.   <li>
  3.     <h2 class="rightNavItem"><a href="#">Show & Hide</a></h2>
  4.     <ul>
  5.       <li><a href="">Links etc here</a></li>
  6.     </ul>
  7.   </li>
  8. </ul>
  9.  
  10. <script>
  11. function enableRightNavExpand() {
  12.         if (!document.getElementById) return false;
  13.         if (!document.getElementById("rightNav")) return false;
  14.         var nav = document.getElementById("rightNav");
  15.         var navItem = nav.getElementsByTagName("li");
  16.         for (var i = 0; i < navItem.length; i++){
  17.                 navItem[i].onclick=function() {
  18.                         if (this.className == "selected") {
  19.                                 this.className = "";
  20.                         }
  21.                         else if (this.className == ""){
  22.                                 this.className = "selected";
  23.                         }
  24.                 }
  25.         }
  26. }
  27. </script>
  28. //javascript/2409

Reply to "JavaScript show and hide UL list"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website