Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. navbar vanliga
  2.  
  3.  
  4. <head>
  5. <div id="mySidenav" class="sidenav">
  6. <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
  7. <a href="/">Hem</a>
  8. <a href="/staffs">Staffs</a>
  9. <button class="dropdown-btn">Test 1-2
  10. <i class="fa fa-caret-down"></i>
  11. </button>
  12. <div class="dropdown-container">
  13. <a href="test-1" target='_blank'>Test 1</a>
  14. <a href="test-2" target='_blank'>Test 2</a>
  15. </div>
  16. <button class="dropdown-btn">Test 2-6
  17. <i class="fa fa-caret-down"></i>
  18. </button>
  19. <div class="dropdown-container">
  20. <a href="test-3">Test 3</a>
  21. <a href="test-4">Test 4</a>
  22. <a href="test-5">Test 5</a>
  23. <a href="test-6">Test 6</a>
  24. </div>
  25. </div>
  26. <span style="font-size:30px;cursor:pointer;color:white;" onclick="openNav()">&#9776; Meny</span>
  27. </head>
  28. <script>
  29. function openNav() {
  30. document.getElementById("mySidenav").style.width = "250px";
  31. }
  32.  
  33. function closeNav() {
  34. document.getElementById("mySidenav").style.width = "0";
  35. }
  36. /* Loop through all dropdown buttons to toggle between hiding and showing its dropdown content - This allows the user to have multiple dropdowns without any conflict */
  37. var dropdown = document.getElementsByClassName("dropdown-btn");
  38. var i;
  39.  
  40. for (i = 0; i < dropdown.length; i++) {
  41. dropdown[i].addEventListener("click", function() {
  42. this.classList.toggle("active");
  43. var dropdownContent = this.nextElementSibling;
  44. if (dropdownContent.style.display === "block") {
  45. dropdownContent.style.display = "none";
  46. } else {
  47. dropdownContent.style.display = "block";
  48. }
  49. });
  50. }
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement