Uncaught SyntaxError: Unexpected ID - Error in Chrome VM

I have this pretty simple code that works, but it returns "Uncaught SyntaxError: Unexpected ID" in Chrome VM3197: 1 What should I do to get rid of it? It seems to me that the code suits me ... The only other code that I run is jQuery and the httml5 template fragment to get rid of console errors in the browser that do not support it.

jQuery(document).ready(function($) {

    var app = (function () {

        var toggleMenu = function(){
            var $offcanvasMenu = $('.offcanvas');
            $offcanvasMenu.toggleClass('-display');
            setTimeout($offcanvasMenu.toggleClass('-show'), 1000);
        };

        return {
            toggleMenu : toggleMenu
        };

    })();

    $('.icon-bars').on('click', function() {
        app.toggleMenu();
    });

});
+1
source share
1 answer

To get rid of unexpected errors, try fixing the code structure.

setTimeout expects the first parameter to be a function, so an anonymous function is needed here:

setTimeout( function(){
    $offcanvasMenu.toggleClass('-show');
}, 1000);
+3
source

Source: https://habr.com/ru/post/1609902/


All Articles