I have a javascript, and I need it to run only with resolutions less than 700px.
Below is my code:
$(document).ready(function(){
$('.menu').hide();
/* menu */
$('.menu').click(function(){
$('.menu').slideToggle(200);
});
});
I have a javascript, and I need it to run only with resolutions less than 700px.
Below is my code:
$(document).ready(function(){
$('.menu').hide();
/* menu */
$('.menu').click(function(){
$('.menu').slideToggle(200);
});
});
You can use the window.screen to grab the screen size. In it you can use the width
and height
properties to get the screen size.
Example:
document.getElementById("width").innerHTML = "Width: " + screen.width + "px";
document.getElementById("height").innerHTML = "Height: " + screen.height + "px";
if (screen.width > 700) {
document.getElementById("resultado").innerHTML = "Width é maior que 700px.";
} else {
document.getElementById("resultado").innerHTML = "Width é menor que 700px.";
}
<p id="width"></p>
<p id="height"></p>
<p id="resultado"></p>
Friend, try to get his resolve and make a simple if.
$(document).ready(function(){
var screenH = window.screen.availHeight;
var screenW = window.screen.availWidth;
if(screenW<700){
alert('run code here');
}
});