vikrant chauhan
vikrant chauhan

Reputation: 1

how can i add function to jquery event

On mouseover event i want to call function which will do somethig when the mouse will be over on images but i dont know how to write code for it.

function reload(){
 $("img.lazy").lazyload({
            effect : "fadeIn",
            event:"mouseover"
           });
}

eg:-

function reload(){
 $("img.lazy").lazyload({
            effect : "fadeIn",
            event:function(moueover)
            {
            //do somthing here
            }
           });
     }

Upvotes: 0

Views: 63

Answers (6)

Jaykumar Patel
Jaykumar Patel

Reputation: 27614

$(document).ready(function(){
    $("img.lazy").lazyload({effect : "fadeIn"}, function() {
         mousehover();
    });
}

function mousehover(){
     //do something mousehover stuff on here
}

Upvotes: 1

Abruzzi
Abruzzi

Reputation: 495

You can just use the event mouseenter below:

$('.lazy').on('mouseenter', function() {
    console.log('foo');
});

Upvotes: 0

TheProvost
TheProvost

Reputation: 1893

You can also use .hover function

$( "img.lazy" ).hover(function() {
$( this ).fadeOut( 100 );
$( this ).fadeIn( 500 );
});

Upvotes: 1

Abhisek Malakar
Abhisek Malakar

Reputation: 899

You can d like this

            jQuery('#youdomid').hover(function(){
                // do your stuff here
              //, your mouse has entered

              alert(2);
            },
            function (){
            // your mose leave the element
               // do the stuff what you want
               alert("leaved");
               }
            )

Upvotes: 1

Yorick de Wid
Yorick de Wid

Reputation: 929

Let's see if this works for you

$(function() {
    $("img.lazy")
        .mouseover(function() { 
            console.log("Mouseover");
        });
});

Upvotes: 1

PeterKA
PeterKA

Reputation: 24638

You want to use mouseenter:

$('.test').on('mouseenter', function() {
  alert( 'mouse is over here' );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="test">Hover here</div>

Upvotes: 1

Related Questions