jQuery 结合 td :not(:first-child) and td:empty

标签 jquery jquery-selectors

我试图在我的 jQuery 代码中组合 td:not(:first-child) 和 td:empty 选择器。我在下面附上了代码摘录。此代码利用hoverIntent插件在1秒的时间延迟后执行功能代码。

$(".jqgrow td:not(:first-child)")
    .mouseenter(function(){
    $.doTimeout('cellhover', 1000, function(e){
        my_tooltip
        .css({opacity:0.85, display:"none"})
        .stop() // Added stop() to fix bug, flickering of tooltip
        .fadeIn(10);                                
    });
});

简单来说,如果鼠标不在表格中的第一列上(该表格包含内容与我的工具提示无关的单元格)并且鼠标所在的单元格不为空,我需要触发该函数。我不确定是使用 td:empty 还是使用 use .html()。

我尝试了以下方法,但没有成功:

$(".jqgrow td:not(:first-child) td:empty")
$(".jqgrow td:empty td:not(:first-child)")
$(".jqgrow td:not(:first-child, :empty)")

我看到了与其他问题相关的使用 .is(:empty) 和 filter() 的想法,但我不知道如何将其应用于这种情况。

如果您有任何帮助,我将不胜感激!

最佳答案

td:empty 选择空的单元格,这与您问题中的描述相反,问题中说明您希望它仅应用于为空的单元格>不为空。

根据您的描述,您的最后一个选择器应该可以工作:

// Select td elements in .jqgrow that are neither :first-child nor :empty
$(".jqgrow td:not(:first-child, :empty)")

如果没有,则说明有其他问题。

关于jQuery 结合 td :not(:first-child) and td:empty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12323102/

相关文章:

jquery - 无法接受来自托管 bean jsf2 primefaces 的 jquery 选择器

javascript - 返回 false 在 jQuery ajax 中不起作用

javascript - JQUERY/JAVASCRIPT - 需要使用 JavaScript 代码从 jquery 对话框上的 <Select> 获取值

php - 我在使用 jquery 提交表单时遇到问题。之前可以正常工作;/

jquery 通过 rel 查找链接

jquery-ui - 如何计算每个 Jquery 语句的执行时间

javascript - .DIV 标签上的按键?

javascript - Jquery 没有使用像 JRate 插件这样的插件处理新添加的元素到 dom

jQuery 验证帮助

javascript - 我可以在同一个命令中放置多个 jquery 选择器吗