Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何向jquery事件添加函数_Javascript_Jquery_Events - Fatal编程技术网

Javascript 如何向jquery事件添加函数

Javascript 如何向jquery事件添加函数,javascript,jquery,events,Javascript,Jquery,Events,在mouseover事件中,我想调用这个函数,当鼠标停留在图像上时,它会做一些事情,但我不知道如何为它编写代码 function reload(){ $("img.lazy").lazyload({ effect : "fadeIn", event:"mouseover" }); } 例如: 您想使用鼠标指针: $('.test')。在('mouseenter',function()上{ 警惕(‘鼠标在这里’); });

在mouseover事件中,我想调用这个函数,当鼠标停留在图像上时,它会做一些事情,但我不知道如何为它编写代码

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


您想使用
鼠标指针

$('.test')。在('mouseenter',function()上{
警惕(‘鼠标在这里’);
});


将鼠标悬停在此处
您想使用鼠标指针

$('.test')。在('mouseenter',function()上{
警惕(‘鼠标在这里’);
});


将鼠标悬停在此处
让我们看看这是否适合您

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

让我们看看这对你是否有效

$(function() {
    $("img.lazy")
        .mouseover(function() { 
            console.log("Mouseover");
        });
});
你会喜欢这个的

            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");
               }
            )
你会喜欢这个的

            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");
               }
            )

您还可以使用.hover函数

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

您还可以使用.hover函数

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

您只需使用下面的事件
mouseenter

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

您只需使用下面的事件
mouseenter

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