How do I change this code snippet so instead of clicking on ‘.close’ I would like to click a second time on ‘.project-name-wrapper’ to make ‘overflow’ → ‘auto’?
<script>
var timesClicked = 0;
$("#menu_button").click(function() {
timesClicked++;
if (timesClicked % 2 == 0) {
//run on each second click
e.preventDefault();
$('body').css('overflow', 'auto');
console.log("second" + timesClicked);
} else {
//run on each first click
e.preventDefault();
$('body').css('overflow', 'hidden');
console.log("first" + timesClicked);
}
});
</script>
Anyway, no way to answer “in general” (Not related to your code/project). Sometimes the counter is wrong (If also there is “Close” button -or- close by esc key and so on). This code is very basic.