-->

Part 8 - JQuery Events - #Document and Windows Events| load, resize, and scroll methods





JQuery Events?
ln this tutorial will discuss about Events in jquery specially, Document/windows Events. We have several type of event types available which consists a lot of methods to perform some action when some event occur.

Event types

1. Mouse Events 
  1. click (): Occurs when a mouse click.
  2. dblclick () :Occurs when a mouse double-click.
  3. mousedown (): Occurs when mouse button is pressed.
  4. mouseup (): Occurs when mouse button is released
  5. mouseenter (): Occurs when mouse enters in an element region.
  6. mouseleave (): Occurs when mouse leaves an element region.
  7. mousemove (): Occurs when mouse pointer moves.
2. Keyboard Events 
  1. Keydown (): Occurs when key is pressed.
  2. Keypress (): Occurs when key is pressed and released.
  3. Keyup (): Occurs when key is released..
3. Form Events 
  1. blur (): Occurs when the element loses focus.
  2. change (): Occurs when the element changes.
  3. focus (): Occurs when the element gets focus.
  4. Submit (): Occurs when form is submitted
  5. Select ():Occurs when input text is selected

4. Document/windows Events 
  1. load (): Occurs when document is loaded.
  2. Resize (): Occurs when window is resized.
  3. Scroll (): Occurs when window is scrolled.
  4. Unload (): Occurs when documents is unloaded. are actions that can be detected by your Web Application.


# Example
Replace your html code with below code 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jquery-3.2.1.min.js"></script>

<script>

$(document).ready(function () {


$("#image1").on("load", function (event) {
var message = "height: " + $(this).height() + " width: " + $(this).width()
$("span").text(message);
})

$("div").scroll(function () {

var message = "scrolled<br/>";
$("span").append(message);
})

})

$(window).resize(function () {

var message = "height: " + $(this).height() + " width: " + $(this).width()
$("span").text(message);
})



</script>
<style>
.btnclass {
height: 200px;
width: 200px;
overflow:scroll;
}
</style>

</head>
<body>
<span></span>

<div class="btnclass" >
<img src="banner.png?dummy=sdfhskdfhihhssssdssssss" id="image1" />

</div>


</body>
</html>

0 Response to "Part 8 - JQuery Events - #Document and Windows Events| load, resize, and scroll methods"

Post a Comment

Popular posts

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel