Skip to content

Instantly share code, notes, and snippets.

@Teckchun
Created April 2, 2017 14:15
Show Gist options
  • Save Teckchun/5b455dbf177c77c52982ea74fc2f2b82 to your computer and use it in GitHub Desktop.
Save Teckchun/5b455dbf177c77c52982ea74fc2f2b82 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script
src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
crossorigin="anonymous"></script>
<style>
.test{
background-color: lightblue;
}
</style>
</head>
<body>
<h1 id="myid" class="test">Hello</h1>
<script>
$(document).ready(function(){
$(window).resize(function(){
console.log($("body").innerWidth())
var bodyWidth = $("body").innerWidth();
if(bodyWidth<1264){
console.log("working");
$("#myid").removeClass('test')
}else{
$("#myid").addClass('test')
}
})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment