JSFiddle - React, Tailwind, and code Playground

by infiniteloops

HTML

<div id="details">
    <div id="child1">child 1</div>
    <div id="child2">child 2</div>
    <div id="child3">child 3</div>
</div>
<a href="#child1">child 1</a>
<a href="#child2">child 2</a>
<a href="#child3">child 3</a>

JavaScript

var checkcurrent = null;
    $(function(){
        $('a').click(function(){
            detailspage($(this).attr('href'));
        });
    });

    function detailspage(page) { 
        if (page != checkcurrent) { 
            var details = $('div#details').children("div"); // so we only have to search the dom once
            checkcurrent = page; 
            details.slideUp("slow");
            $.when(details).done(function(){
                $('div' + page).slideDown("slow"); 
            });
        }; 
    };