How to use mouseenter( ) and mouseleave( ) method in JQuery

February 18, 2016 0 Comments

The meaning of mouse enter and mouse leave are, when your cursor enter your object bounary then mouse enter method raised similarly when your cursor goes out of your object boundary then mouse leave method raised. I will give you an example of mouse enter and mouse leave method. Lets see the example, in this, we have division, when your cursor move on your divison boundary then division background changed also text of division will be changed. This also contain mouseleave() method with the same functionality.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default22.aspx.cs" Inherits="Default22" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <script src="Scripts/jquery-1.10.2.js"></script>
            $('div').mouseenter(function () {
                $(this).css('background-color', 'green');
                $(this).html('MY website')

            $('div').mouseleave(function () {
                $(this).css('background-color', 'red');
                $(this).html('MY Blog');


    <form id="form1" runat="server">
    <div style="height:50px;width:50px">
    Hello World !

Code generates the following output

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google