Jump to content
Sign in to follow this  
Guest MatheusT

Alguém poderia me ajudar a entender o código Jquery?

Recommended Posts

Guest MatheusT

Olá, eu estou começando a aprender Jquery, alguém poderia me explicar como funciona esse código abaixo?

$(function() {  
  menu = $('nav ul');

  $('#openup').on('click', function(e) {
    e.preventDefault();
    menu.slideToggle();
  });

  $(window).resize(function() {
    var w = $(this).width();
    if (w > 480 && menu.is(':hidden')) {
      menu.removeAttr('style');
    }
  });   

  $('nav li').on('click', function(e) {
    var w = $(window).width();
    if (w < 480) {
      menu.slideToggle();
    }
  });
  $('.open-menu').height($(window).height());
});

eu tenho a barra de menu em html

<header>
      <nav class='bar'>
        <ul class='bar'>
          <li class="screen-small">
            <a href="#showcase">Lorem Ipsum</a>
          </li>
          <li>
            <a href='#showcase'>Home</a>
          </li>
          <li>
            <a href='#music'>Music</a>
          </li>
          <li>
            <a href='#video'>Video</a>
          </li>
          <li>
            <a href='#premium'>Premium</a>
          </li>
        </ul>
        <a href='#' id='openup'>myTunes</a>
      </nav>
    </header>

 

Edited by MatheusT

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.