I am having throuble using the jQuery to change some CSS style. This is the jsfiddle:
When I re-size the browser, my div does not change the properties. Any help would be great full. And here is the code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- change css style -->
<script type="text/javascript">
$(document).resize(function() {
var red = $('.red');
red.on('resize', function(){
if ( red.width() < 600 ){
red.addClass('green');
}
});
});
</script>
<style type="text/css">
.red {
height: 500px;
margin: 0 auto;
background-color: #F00;
width: 80%;
max-width: 1000px;
}
.green {
width: 100px;
background-color: #0F0;
height: 500px;
}
</style>
</head>
<body>
<div class="red">
</div>
</body>
</html>
Thanks,
red.on('resize', ...)to do? The DIV isn't resizeable.