HTML
Код:
<link rel="stylesheet" href="https://forumstatic.ru/files/0011/8c/a9/84432.css"> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="https://forumstatic.ru/files/0011/8c/a9/74074.js"></script> <ul class="menu"> <li tabindex="1"> <span class="title">One</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Two</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Three</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Four</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Five</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Six</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Seven</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Eight</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> <li tabindex="1"> <span class="title">Nine</span> <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div> </li> </ul> <script> (function(){ // Append a close trigger for each block $('.menu .content').append('<span class="close">x</span>'); // Show window function showContent(elem){ hideContent(); elem.find('.content').addClass('expanded'); elem.addClass('cover'); } // Reset all function hideContent(){ $('.menu .content').removeClass('expanded'); $('.menu li').removeClass('cover'); } // When a li is clicked, show its content window and position it above all $('.menu li').click(function() { showContent($(this)); }); // When tabbing, show its content window using ENTER key $('.menu li').keypress(function(e) { if (e.keyCode == 13) { showContent($(this)); } }); // When right upper close element is clicked - reset all $('.menu .close').click(function(e) { e.stopPropagation(); hideContent(); }); // Also, when ESC key is pressed - reset all $(document).keyup(function(e) { if (e.keyCode == 27) { hideContent(); } }); })(); </script>