使用selector |隐藏父元素带过滤器功能(jQuery) [英] Hiding parent element with selector | with filter function (jQuery)

查看:222
本文介绍了使用selector |隐藏父元素带过滤器功能(jQuery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在包含少于250个种子的 http://ThePirateBay.se 上隐藏搜索结果。我的问题是,我不知道如何使用过滤器选项来检测种子元素,而且在检测到数字范围时隐藏父元素。下半部分不工作。

I am wanting to hide search results on http://ThePirateBay.se that contain less than 250 seeds. My problem is, I am not sure how to use the filter option to detect the seeds element, but also hide the parent element when the number range is detected. The second half doesn't work. Help is appreciated.

$(document).ready(function(){
    var tds=$("td").filter(function() {
        if($(this).text()>250&&$(this).text()<25000){
            return this;
        }
    });
    tds.css( {"text-decoration":"underline" , "color":"#383"});
});


$(document).ready(function(){
    var tds=$("TD > #searchResult TR").filter(function() {
        if($(this).text()>001&&$(this).text()<249){
            return this;
        }
    });
    tds.css( {"opacity":"0.35" , "color":"#777"});
});






jQuery网页注入器自我测试: https://chrome.google.com/webstore/detail/jscript-tricks/odialddippdmebbfbflcneemfdglimod (JScript Tricks)


jQuery webpage injector to self test: https://chrome.google.com/webstore/detail/jscript-tricks/odialddippdmebbfbflcneemfdglimod (JScript Tricks)

PS,第二半不工作,两个部分都不工作。

P.S, with the 2nd half not working, both parts become non-working.

推荐答案

必须在比较之前将文本解析为int

You must parse text to int before comparing like this

$(document).ready(function(){
    var tds = $("td").filter(function() {
        return (+$(this).text() > 250 && +$(this).text() < 25000);
    });
    tds.css( {"text-decoration":"underline" , "color":"#383"});
});


$(document).ready(function(){
    var tds = $("TD > #searchResult TR").filter(function() {
        return (+$(this).text() > 1 && +$(this).text() < 249);
    });
    tds.css( {"opacity":"0.35" , "color":"#777"});
});

这篇关于使用selector |隐藏父元素带过滤器功能(jQuery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆