I've set up this code so that on click of the div. to toggle and remove a class. now i would like to add different classes in different size of windows. i wrote the below code but this code is not working. here is my code :
$('.click').click( function() {
var windowsize = $window.width();
if (windowsize = 1920) {
$(".add").toggleClass("new920");
}
} );
$(".click").click(function(){
var windowsize = $window.width();
if (windowsize = 1280) {
$(".add").toggleClass("new280");
}
});
.click{ border:1px solid #CCC; width:100px; height:20px;}
.add{ width:200px; height:300px; background:#ccc;}
.new920{ background:red !important;}
.new280{ background:green !important;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<html>
<head>
</head>
<body>
<div class="click">click</div><br/>
<div class="add">Add</div>
</body>
</html>