I don't understand the syntax


Interactive Website: Push Menu #5

This is where my problem started, although it allowed me to advance to #8 even though I don't understand anything. So I stopped and started over.

I don't understand the syntax of it. All the parentheses, curly brackets, periods, dollar signs and single quotations. If someone can just explain to me what they are and what goes before/between/after them, I'll have a much better understanding of all of this, and would be able to complete exercises like this by myself without copying the hint.

Rather odd that the lesson itself never even brushed on them. That said, I never did the JavaScript lesson, so I'm not sure if it's there.

As for my code specifically, I just copied the hint, but even though it allows me to advance, I have yet to successfully see any response from the page on the right, even until exercise #8.



+++++ 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:

         |                |
        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" )
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 )_

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
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

explanation of the push-menu setup


google search
class site:jquery.com

what is CSS explained site:developer.mozilla.org



This happened to me too. I started this lesson, and the lack of explanation of what everything is just went over my head.

I went and did the Java Script and Jquery modules first, now ive come back this and its all making more sense, so i would advise you to do the same if you havent already :slight_smile: