Trigger mouse over event

Description

The following code shows how to trigger mouse over event.

Example


<html>
<head>
<style type="text/css">
div {<!--from www.j av  a 2  s . c  om-->
  padding: 10 10 10 10;
  width: 100;
  height: 100;
}

.div1 {
  background-color: blue;
}

.div2 {
  background-color: yellow;
}

.div3 {
  background-color: green;
}
</style>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
  $(document).ready(function() {
    $("p").hide();
    $(".div1", this).mouseover(function() {
      $(this).find("p").fadeIn().fadeOut();
    });
    $(".div2", this).mouseover(function() {
      $(this).find("p").fadeIn().fadeOut();
    });
    $(".div3", this).mouseover(function() {
      $(this).find("p").fadeIn().fadeOut();
    });
    $("input").click(function() {
      $("div").trigger("mouseover");
    });
  });
</script>
</head>
<body>
  <div class="div1">
    <p>java 2 s.com</p>
  </div>
  <div class="div2">
    <p>ja va2s.com</p>
  </div>
  <div class="div3">
    <p>java2s.com</p>
  </div>
  <input type="button" value="run with trigger"></input>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities