隐藏包含“某个字符串"的元素(li)? [英] Hide element (li) that contains "some string"?

查看:49
本文介绍了隐藏包含“某个字符串"的元素(li)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏许多包含(内部 HTML)字符串whatever"的

  • 元素.有没有办法在不知道 <li> s的innerHTML的确切结构的情况下做到这一点?

    I want to hide one <li> element of many which contains (inner HTML) the string "whatever". Is there way to do that without knowing the exact structure of the innerHTML of the <li>s?

    我知道如何隐藏它,只是发现是问题所在.我可以使用 Prototype 来做到这一点.

    I know how to hide it, just the finding is the problem. I can use Prototype to do that.

    推荐答案

    你可以这样做:

    $$("li:contains('whatever')").invoke("hide");
    

    解释一下:$$("li:contains('whatever')") 返回一个包含whatever"的

  • 列表,并且然后我们对该列表中的所有内容调用 hide 方法.

    To explain: $$("li:contains('whatever')") returns a list of <li>s that contain "whatever", and then we invoke the hide method on everything in that list.

    这是一个 jsFiddle.

    这篇关于隐藏包含“某个字符串"的元素(li)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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