dimanche 18 septembre 2016

Run code if screen has certain width

I'm just trying to write a message in the console when the size of the window is less than 700 px.

The things I have tried is:

if(window.innerWidth < 700){
console.log("hello");
}

And

if(screen.width < 700){
console.log("hello");
}

I don't get any error meassages but the code doesn't run. If I ad "px" after the 700 I get the error meassage "Uncaught SyntaxError: Unexpected identifier".

Aucun commentaire:

Enregistrer un commentaire