I'm setting up the the webpage so that, at a certain width, the right side sliding menu will become a top to bottom sliding menu. To do so, I've used javascript to change the onclick attribute of the buttons but still the webpage keeps on working like before, with a right to left sliding effect. I attach the code related to the menu.
html:
<div id="header">
<header id="title">
<h1>The Nest</h1>
<p id="para">The hostel where your journey should start</p>
<button type="button" class="btn btn-lg" id="menu-btn" onclick="openSide()">
<span class="glyphicon glyphicon-list"></span>
</button>
</header>
</div>
<div id="sidebar">
<a href="javascript:void(0)" id="close-btn" onclick="closeSide()">×</a>
<a href="#">Accomodations</a>
<a href="#">Services</a>
<a href="#">Merchandising</a>
<a href="#">About us</a>
</div>
javascript & jQuery:
var main = function() {
$(window).resize(function() {
var width = $(window).width();
if (width < 1023) {
document.getElementById("para").innerHTML = "Barcellona fine stay";
$("#menu-btn").click(function() {
$("#para").fadeOut("fast");
$("#menu-btn").fadeOut("fast");
});
$("#close-btn").click(function() {
$("#para").fadeIn("slow");
$("#menu-btn").fadeIn("slow");
});
}
else if (width > 1024) {
document.getElementById("para").innerHTML = "The hostel where your journey should start";
}
else if (width < 380) {
document.getElementById("menu-btn").onclick = function() { openTop(); };
document.getElementById("close-btn").onclick = function() { closeTop(); };
$("#menu-btn").click(function() {
$("#header").fadeOut("fast");
});
$("#close-btn").click(function() {
$("#header").fadeIn("slow");
});
}
return true;
});
}
$(document).ready(main);
I've just added the whole if/else statement because it seems that the whole last "else if" it doesn't work