Push Menu wont work at all


#1

Im Stuck on the push menu and i dont know whats wrong.

https://www.codecademy.com/en/courses/web-beginner-en-zmn0b/0/5?content_from=make-an-interactive-website%3Ayour-first-program

I keep checking the code but it all seem to be correct. I also tried to sort out the CSS which i read on other conversations where others were struggling to get the menu to work.

Here's my code so you can check:

var main = function(){
    $('.icon-menu').click(function();
    
    
;}
$(document).ready(main);

#2

@quakejay,

+++++ DOM representation of push menu

If your HTML-page is loaded into memory by the Browser
the memory-layout will be build
using the rules, as defined in the Document Object Model
in short the DOM

The DOM representation of the index.html file would look like:

               html
                |
         +------+---------+
         |                |
        head             body
         |                |
    +----+----+      +----+-----------+
    |    |    |      |                |
   link link link  10div(.menu)     27div(.jumbotron)
                    |                 |
     +--------------+----+          29div(.icon-menu)
     |                   |             |
   13div(.icon-close)  18ul          30i (.fa
     |                   |             |  and .fa-bars)
    img       +-----+----++-----+    text  
              |     |     |     |    node
             19li  20li  21li  22li
              |     |     |     |
              a     a     a     a
              |     |     |     |
            text   text  text  text
            node   node  node  node

Now if you look at the DOM representation
the body-Tag is parent to
a 10div Element's Tree ( with class-attribute with class-name "menu" )
and
a 27div Element's Tree ( with class-attr. with class-name "jumbotron" set )

Now if you look in the style.css file,
with which you manage the Display of your Elements,
you will find that
the body object has the property left: 0; being set
( the body-Tree has a _start-Display at position left-0 )_

but
the .menu object has the property left: -285px; being set
and therefor the 10div-Tree is outside of Display.

In your 'app.js' file you are
CREATING a VARIABLE main
to which you assign a so-called anonymous Function
and in the FUNCTION-BODY of this anonymous Function
we are attaching our click Event-handlers
to the HTML-Elements which are
-1 carrying the "icon-menu" class-name as class-attribute
-2 carrying the "icon-close" class-name as class-attribute
( during the assignment the function is NOT executed )

You will have to add the code-line
$(document).ready( main );
which will result in the =main= Function to be executed
AFTER the Browser has set the ready Event-flag.

++++++++++ structure P u s h M e n u function
The structure of your =main= Function should look like....

  var main= function() {
     $('.icon-menu').click( function() {
           //Your animation
     });

     $('.icon-close').click( function() {
           //Your animation
      });
   };
 $(document).ready(main);

explanation of the push-menu setup
https://www.codecademy.com/forum_questions/55b3d3c1d3292f529b00005e


#3

this has not helped im afraid


#4

Can anyone else give me any help as the push menu will just not work for me at all


#5

Your missing a few things.

In between $('.icon-menu').click(function(); and ;}(Note, you should change your ;} to }; you need:

 $('.menu').animate({
        left: '0px'
      }, 200);
    
     $('body').animate({
        left : '285px'
    },200);
})

#8

It's actualy the fault of the instructions. If you are a beginner, it is missing a lot of things that it needs to explain to you as you simply wouldn't know them. No where in the course before this point has it explained how to out miliseconds timinings in either.

In comparison to the HTML and CSS course, the Javascript and Jquery course is incredibly poor.


#9

/*open menu */ is missing from the hint instructions. There's no way you'd know to put that in either!!