jQuery:.parent()如果数值范围从0开始,则不会隐藏

时间:2016-10-13 23:45:43

标签: javascript jquery greasemonkey

我在元素中使用数值范围检测时会遇到一些问题,然后隐藏另一个元素。当范围从1+开始时它似乎工作正常,但它在0+时断开。它们是我尝试过的不同迭代代码,但到目前为止还没有运气。

这是我试图使用我的greasemonkey脚本的网站: https://openuserjs.org/?orderBy=updated&orderDir=desc

目的:如果安装了0-100,我想隐藏列出的项目。

这是我的脚本:https://ghostbin.com/paste/zujku

以下是我尝试使用但失败的代码的三种变体:

$("TR .text-center.td-fit").each(function() { 
if ($(this).text() >= 0 && $(this).text() <= 100){
$(this).parent().hide();
}
});


$(document).ready(function(){
var tds = $("TR .text-center.td-fit").filter(function() {
return (+$(this).text() > 0 && +$(this).text() < 100);
});
tds.parent().hide();
});


$("TR .text-center.td-fit").each(function() { 
if ($(this).text() >= 0 && $(this).text() <= 100){
$(this).parent().hide();
}
});

注意:“。text-center.td-fit”是主列表项(TR)上的'installs'元素

2 个答案:

答案 0 :(得分:1)

试试这个:

CREATE FUNCTION getSelected2
(    
)
RETURNS @res TABLE 
(
    id int, EntryTime DATETIME, ResultTime DATETIME, Symbol char(3)
)
AS
BEGIN
    declare @idC int;
    declare @ResultTimeC DATETIME;
    declare @EntryTimeC DATETIME;
    declare @SymbolC char(3);
    declare @lastNextDate DATETIME; 
    declare @lastSymbol char(3);

    DECLARE Iterator CURSOR FAST_FORWARD 
    FOR SELECT id, EntryTime, ResultTime, Symbol FROM dbo.tt2 order by Symbol, EntryTime, id
    OPEN Iterator
    WHILE 1=1 BEGIN
        FETCH NEXT FROM Iterator INTO @idC, @EntryTimeC, @ResultTimeC, @SymbolC
        IF @@FETCH_STATUS < 0 BREAK 

        if(@lastSymbol is null or @lastSymbol <> @SymbolC) begin
            set @lastSymbol = @SymbolC;
            set @lastNextDate = null;
        end;
        if(@lastNextDate is null or @lastNextDate < @EntryTimeC) begin
            set @lastNextDate = @ResultTimeC;
            insert into @res (id, EntryTime, ResultTime, Symbol) values (@idC, @EntryTimeC, @ResultTimeC, @SymbolC);
        end;            
    END
    CLOSE Iterator
    DEALLOCATE Iterator;

    RETURN 
END

答案 1 :(得分:0)

我在firefox附加商店中使用AdBlock元素隐藏来解决这个问题。通过一些组合/尝试,我发现这个组合起作用

AdBlock Element Hider选择:

THEAD + * TD:first-child + .text-center.td-fit > P

目前的工作版本:

$("THEAD + * TD:first-child + .text-center.td-fit > P").each(function() { 
if ($(this).text() >= 0 && $(this).text() <= 70){
    $(this).parent().parent().hide();
    }
});