Line 87: | Line 87: | ||
</style> | </style> | ||
− | < | + | <script> |
− | + | $('.toggle').click(function(e) { | |
+ | e.preventDefault(); | ||
+ | |||
+ | var $this = $(this); | ||
+ | |||
+ | if ($this.next().hasClass('show')) { | ||
+ | $this.next().removeClass('show'); | ||
+ | $this.next().slideUp(350); | ||
+ | } else { | ||
+ | $this.parent().parent().find('li .inner').removeClass('show'); | ||
+ | $this.parent().parent().find('li .inner').slideUp(350); | ||
+ | $this.next().toggleClass('show'); | ||
+ | $this.next().slideToggle(350); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | </script> | ||
+ | |||
+ | <body> | ||
+ | <div class="w3-center"> | ||
<ul class="accordion"> | <ul class="accordion"> | ||
Line 164: | Line 183: | ||
</li> | </li> | ||
</ul> | </ul> | ||
− | </div> | + | </div> |
</body> | </body> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</html> | </html> | ||
{{Northwestern_Page_Foot}} | {{Northwestern_Page_Foot}} |
Revision as of 18:04, 25 August 2017
-
Item 1
- Option 1
- Option 2
- Option 3
-
Item 2
- Option 1
- Option 2
- Option 3
-
Item 3
-
Open Inner
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tempus placerat fringilla. Duis a elit et dolor laoreet volutpat. Aliquam ultrices mauris id mattis imperdiet. Aenean cursus ultrices justo et varius. Suspendisse aliquam orci id dui dapibus blandit. In hac habitasse platea dictumst. Sed risus velit, pellentesque eu enim ac, ultricies pretium felis.
-
Open Inner #2
Children will automatically close upon closing its parent.
- Option 3
-
Open Inner
-
Item 4
-
Technically any number of nested elements
-
Another nested element
As long as the inner element has inner as one of its classes then it will be toggled.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tempus placerat fringilla. Duis a elit et dolor laoreet volutpat. Aliquam ultrices mauris id mattis imperdiet. Aenean cursus ultrices justo et varius. Suspendisse aliquam orci id dui dapibus blandit. In hac habitasse platea dictumst. Sed risus velit, pellentesque eu enim ac, ultricies pretium felis.
-
Another nested element
- Option 2
- Option 3
-
Technically any number of nested elements