相关疑难解决方法(0)

如何检查鼠标是否在jQuery中的元素上?

有没有一种快速简便的方法在jQuery中做到这一点,我错过了?

我不想使用鼠标悬停事件,因为我已经将它用于其他事情.我只需要知道鼠标是否在给定时刻超过元素.

如果只有"IsMouseOver"功能,我想做这样的事情:

function hideTip(oi) {
    setTimeout(function() { if (!IsMouseOver(oi)) $(oi).fadeOut(); }, 100);
}
Run Code Online (Sandbox Code Playgroud)

jquery mouseover

261
推荐指数
10
解决办法
32万
查看次数

jquery直播悬停

我正在使用以下jquery代码来显示我们用鼠标悬停的表行的上下文删除按钮.这适用但不适用于已随js/ajax添加的行...

有没有办法让这个工作与现场活动?

$("table tr").hover(
  function () {},
  function () {}
);
Run Code Online (Sandbox Code Playgroud)

jquery live jquery-1.4

162
推荐指数
5
解决办法
10万
查看次数

JQuery .on()方法,具有一个选择器的多个事件处理程序

试图弄清楚如何将Jquery .on()方法与具有多个与之关联的事件的特定选择器一起使用.我之前使用过.live()方法,但不太确定如何用.on()完​​成同样的壮举.请参阅下面的代码:

$("table.planning_grid td").live({
  mouseenter:function(){
     $(this).parent("tr").find("a.delete").show();
  },
  mouseleave:function(){
     $(this).parent("tr").find("a.delete").hide();        
  },
  click:function(){
    //do something else.
  }
});
Run Code Online (Sandbox Code Playgroud)

我知道我可以通过调用以下方式分配多个事件:

 $("table.planning_grid td").on({
    mouseenter:function(){  //see above
    },
    mouseleave:function(){ //see above
    }
    click:function(){ //etc
    }
  });
Run Code Online (Sandbox Code Playgroud)

但我相信正确使用.on()会是这样的:

   $("table.planning_grid").on('mouseenter','td',function(){});
Run Code Online (Sandbox Code Playgroud)

有没有办法实现这个目标?或者这里的最佳做法是什么?我尝试了下面的代码,但没有骰子.

$("table.planning_grid").on('td',{
   mouseenter: function(){ /* event1 */ }, 
   mouseleave: function(){ /* event2 */ },
   click: function(){  /* event3 */ }
 });
Run Code Online (Sandbox Code Playgroud)

提前致谢!

javascript jquery jquery-selectors jquery-1.7

128
推荐指数
5
解决办法
14万
查看次数

通过AJAX加载内容后jQuery不起作用

这个页面上,我有一个jQuery弹出窗口和缩略图可调整大小的图像.如果我将鼠标悬停在缩略图上,则图像会完美调整大小.此外,当我点击页脚中的大黄色电视按钮"QuickBook TV"时,弹出窗口完全按照我的要求显示.

但是,当我单击"下一步"或"上一页"按钮时,AJAX用于加载新内容,而我的jQuery不再适用于弹出窗口或缩略图图像.我搜索了很多论坛,寻找有关此问题的信息,但由于对jQuery的了解有限,我无法理解我需要做什么.

以下是弹出式jQuery

$(document).ready(function() {

        $(".iframe").colorbox({ iframe: true, width: "1000px", height: "500px" });
        $(".inline").colorbox({ inline: true, width: "50%" });
        $(".callbacks").colorbox({
            onOpen: function() { alert('onOpen: colorbox is about to open'); },
            onLoad: function() { alert('onLoad: colorbox has started to load the targeted content'); },
            onComplete: function() { alert('onComplete: colorbox has displayed the loaded content'); },
            onCleanup: function() { alert('onCleanup: colorbox has begun the close process'); },
            onClosed: function() { alert('onClosed: colorbox has completely closed'); }
        });

        //Example of …
Run Code Online (Sandbox Code Playgroud)

ajax jquery

56
推荐指数
2
解决办法
7万
查看次数

怎么告诉.hover()等?

我有一个下拉菜单.现在当它下滑到多个级别时,我希望在它消失之前添加等待时间为2秒,这样用户可以在.hover()错误打破时重新进入状态.

可能吗?

我的幻灯片代码:

$('.icon').hover(function() {
        $('li.icon > ul').slideDown('fast');
    }, function() { 
        $('li.icon > ul').slideUp('fast');
    });
Run Code Online (Sandbox Code Playgroud)

javascript time jquery hover settimeout

49
推荐指数
2
解决办法
6万
查看次数

jQuery - 悬停不起作用

遇到一点麻烦 .hover()

我正抓住一些运球镜头,这些镜头在页面加载时被拉入.由于某些原因,通过悬停添加一个类不希望对它们起作用.

虽然它与标准列表完美配合.

jsFiddle在这里

JS:

$("#dribbble li").hover(

function () {
    $(this).addClass("hover");
},

function () {
    $(this).removeClass("hover");
});
Run Code Online (Sandbox Code Playgroud)

HTML

<div id="dribbble">
<ul>
    <li></li>
    <li></li>
    <li></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

html jquery

8
推荐指数
2
解决办法
2万
查看次数

自制jQuery无法正确处理事件

更新:可能是jQuery的触发器()在测试中做了一些额外的工作,我在github上打开了一个问题.

=====

我正在关注learnQuery来构建我的简单jQuery.现在正在研究DOM事件,实现on()off()功能.他们提供了一些测试,我无法通过其中一些测试.

这是我的代码:( 你可以克隆这个分支,运行06.event_listeners/runner.html以运行测试)

"use strict";

function isEmpty(str) {
    return (!str || 0 === str.length);
}

// listener use to bind to DOM element, call corresponding functions when event firing.
function geneEventListener(event) {
  console.log('gene');
  let type = Object.keys(this.handlers).find(type=>type===event.type);
  if (!type) return;
  let functions = this.handlers[type];
  functions.forEach(f=>f.apply(this,event));
}

// cache elements which bound event listener
let Cache = function () {
  this.elements = [];
  this.uid = 1; …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

7
推荐指数
1
解决办法
198
查看次数

jQuery绑定悬停到"文档"

是否可以将hover()绑定到具有指定选择器的文档,以便为具有匹配属性的动态添加内容分配JS函数?

我一直在看这个主题:JQuery .on()方法,一个选择器有多个事件处理程序,是否可以使用jQuery .on和hover?

而我目前正在使用:

$('.profile-gallery-image-container').on({
    mouseenter: function(){
        $('.delete-image', this).show();
        $('.image-options', this).show();
    },
    mouseleave: function(){
        $('.delete-image', this).hide();
        $('.image-options', this).hide();
    }
}, '.profile-gallery-image-container');
Run Code Online (Sandbox Code Playgroud)

但无法通过匹配选择器将功能传递给新内容.

jquery

2
推荐指数
1
解决办法
5235
查看次数

JQuery - 使用hover()和on()

我尝试使用jquery的on() - 方法与hover()结合使用.我希望用户将鼠标悬停在div上,显示一个值,当他将鼠标移离该div时再次看到旧值,但这不起作用...有人有线索吗?

$('#content').on('hover', '.player_marktwert_box',
    function() {
    var playerValue = $(this).html();
        $(this).html("test");
    },
    function () {
        $(this).html(playerValue);
    }
);
Run Code Online (Sandbox Code Playgroud)

谢谢!

jquery

1
推荐指数
1
解决办法
151
查看次数