Events are the strength of jquery. There are different types of events for different purposes in jquery such as click,change etc. We are going to discuss one of the events named resize. It will be applied on the window size change. It will call a function whenever window's size changes.
Let us take a simple example:
<html>
<head>
<script type="type/javascript">
jQuery(function($){
jQuery(window).resize(function(){
jQuery("#window-msg").html("<div>" + $( window ).width() + "</div>");
});
});
</script>
</head>
<body>
<div id="window-msg"></div>
</body>
<html>
This example will show the width of the window whenever window's size changes.
0 Comment(s)