Jump to content


One Button 2 Functions

  • Please log in to reply
No replies to this topic

#1 JoannePinna


    New Member

  • Members
  • Pip
  • 1 posts

Posted 10 August 2012 - 01:10 PM

Hello I am a newbie in javascript and jquery. I have this button on my page that toggles a nav when pressed. When toggled, only content shows which is below the nav in the same html page. This works great for what I need. But I would like the same button, when showing the navigation to hide the content. Is it possible? Here is the code:

if (window.innerWidth && window.innerWidth <= 480) {
$('#header ul').addClass('hide');
$('#header').append('<div class="rightButton" onclick="toggleMenu()">Menu</div>');
function toggleMenu() {
$('#header ul').toggleClass('hide');
$('#header .rightButton').toggleClass('pressed');
if(pressed) {
$('#content').toggleClass('hide'); }


I would greatly appreciate help!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users