O'Reilly Forums: One Button 2 Functions - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

One Button 2 Functions Need help in adding function to a button

#1 User is offline   JoannePinna 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 10-August 12

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) {
$(document).ready(function(){
$('#header ul').addClass('hide');
$('#content').addClass('show');
$('#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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users