M
M
Mikhail Gilmutdinov2015-07-28 14:06:52
JavaScript
Mikhail Gilmutdinov, 2015-07-28 14:06:52

How can Javascript specify an additional condition depending on the width of the browser?

How to make a condition in JS be executed only at a certain browser width?

$(window).load(function() {
  $('.nav_slide_button').click(function() {
    $('.pull').slideToggle();
  });
});

<nav class="pull"> 
<ul class="nav navbar-nav navbar-right">
<li><a href="#intro">1-ый пункт</a></li>
<li><a href="#contact">Контакты</a></li>
</ul>
</nav>

@media screen and (max-width:991px) {
  .pull { display: none; }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-07-28
@Mixailhr

if($(window).width() > 800){
// Any of your code here
}

R
Rafael™, 2016-04-14
@maxminimus

https://developer.mozilla.org/en-US/docs/Web/API/W...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question