E
E
Evgeniy Gaidukov2020-05-05 16:04:47
JavaScript
Evgeniy Gaidukov, 2020-05-05 16:04:47

How to set the default class at a specific resolution?

There is such a code that opens and closes the side menu, they asked to fasten the property so that when the screen width is < 1770px, the menu is already open by default. I understand what is being done in a couple of lines, but something goes wrong.

$('.leftcolumn__close-link').click(function() {
            $('.leftcolumn').toggleClass('open');
            $('#overlay').toggle();
            $('body').toggleClass('position-fixed');
            $('.leftcolumn').addClass('open');
        })

        $('#overlay').click(function() {
            $('#overlay').hide();
            $('.leftcolumn').toggleClass('open');
            $('body').toggleClass('position-fixed');
        })


All I could think of was to screw over the code

$(document).ready(function(){
            if ( $(window).width() < 1770) {
                $('.leftcolumn').addClass('open');
            }
        });

But doesn't work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dubolom Unicellular, 2020-05-05
@Sevuz-Bek

This is a less than sign, put a >= sign (greater than equals), then even if the screen is exactly 1770, the section will be hidden

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question