My menu aims at navigating within the same long page. Only one menu item (corresponding to the section of the page being viewed currently) is visible by default. A click on that visible menu item reveals the whole menu.
Here's the trick: once the menu is revealed, another click (not talking abut double click here) on a menu item should trigger something else, namely scrolling to the area associated with the item (off topic here). Is it achievable with jQuery
alone?
Somehow I need to make the alert()
part execute only on the second click, not the first.
Here's my code so far: https://jsfiddle.net/v6rLs1rg/
jQuery(document).ready(function($) {
$('.current').click(function() {
$('.menu_item').fadeIn();
});
$('.menu_item').click(function() {
alert('test');
});
});
.menu_item {
display: none;
}
.current {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="menu_item">
Item 1
</div>
<div class="menu_item current">
Item 2
</div>
<div class="menu_item">
Item 3
</div>
</div>