The 'O' Shortcut


#1

My code is pasted below. I don't understand what I'm missing here. I've been through it time and time again and cannot seem to find my error.

var main = function() {
        $('.article').click(function() {
        $('.article').removeClass('current');
        $('.description').hide();
        $(this).addClass('current');
        $(this).children('.description').show();
        
    });
    
    $(document).keypress(function(event) {
        if(event.which === 111) {
            $('.current').children('.description').toggle();
        }
    };
});
    <div class="article">
        
        <div class="item">
    
        </div>
    
        <div class="description">
        
        </div>
    </div>
};

$(document).ready(main);

#2

Hi Zack,

First, separate your HTML and JavaScript. HTML looks like this:

<div>...</div>

and JavaScript is the stuff you've been writing so far, if (...) {...}, var main = function() {...}, etc.. HTML belongs in your index.html file, and the JS belongs in app.js.

Then, remove the closing curly brace on line 14; it closes the main function early and throws a syntax error.

Please let me know if you need any more help! :slight_smile: