Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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 悬停区的射击功能_Javascript_Jquery_Hover - Fatal编程技术网

Javascript 悬停区的射击功能

Javascript 悬停区的射击功能,javascript,jquery,hover,Javascript,Jquery,Hover,我试图在你翻滚到红色区域时启动一个函数 有什么建议吗 $(document).ready(function() { $("#wrapper").bind('mousemove', function(e) { $("#tail").css({ top: e.pageY }); }); }); 添加:要返回到起始位置: $(document).ready(function() { $("#wrapper").hove

我试图在你翻滚到红色区域时启动一个函数

有什么建议吗

$(document).ready(function() {
    $("#wrapper").bind('mousemove', function(e) {
        $("#tail").css({
            top: e.pageY
        });
    });
});
添加:要返回到起始位置:

$(document).ready(function() {
    $("#wrapper").hover(function() {
        $.data(this, "tail_Y", $("#tail").css("top"));
    }, function() {
        $("#tail").css("top", $.data(this, "tail_Y"));
    }).bind('mousemove', function(e) {
        $("#tail").css({
            top: e.pageY
        });
    });
});

添加:要返回到起始位置:

$(document).ready(function() {
    $("#wrapper").hover(function() {
        $.data(this, "tail_Y", $("#tail").css("top"));
    }, function() {
        $("#tail").css("top", $.data(this, "tail_Y"));
    }).bind('mousemove', function(e) {
        $("#tail").css({
            top: e.pageY
        });
    });
});

这有什么帮助吗

$(document).bind('mousemove', function(e){
    $('#tail').css({
       top:   e.pageY
    });
    $('#wrapper').click(function(){    
    xyz();

     });
});


function xyz()
{
        alert('hello');
}
希望这有帮助

$(document).bind('mousemove', function(e){
    $('#tail').css({
       top:   e.pageY
    });
    $('#wrapper').click(function(){    
    xyz();

     });
});


function xyz()
{
        alert('hello');
}
试试这个:

$("#wrapper").mouseover(function() {
   // your function here
   alert("mouse over red area");
});
试试这个:

$("#wrapper").mouseover(function() {
   // your function here
   alert("mouse over red area");
});

一旦dom就绪,您必须确保运行以下代码:

$("#wrapper").bind('mouseenter', function(e) {
   alert("Entered Wrapper")
});

您必须确保在dom就绪后运行以下代码:

$("#wrapper").bind('mouseenter', function(e) {
   alert("Entered Wrapper")
});

太棒了,有没有办法让尾巴回复到原来的位置?你会在鼠标移出时删除CSS功能吗?@dzejkej是的!非常感谢你,有没有办法让尾巴回复到原来的位置?你会在鼠标移出时删除CSS功能吗?@dzejkej是的!非常感谢你