Jquery“包含”多个值 [英] Jquery "contains" multiple values

查看:103
本文介绍了Jquery“包含”多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现文档中包含文本内的所有div:'thetext',我正在更改此文本:

I am finding all the divs in a document which contains inside a text: 'thetext' and i am changing this text:

$("div:contains('thetext'):not(:has(*))").each(function () {

  $(this).text($(this).text() + " anotherTextAddedBefore");

 })

是它可以放在里面包含多个值?
我想找到包含的div:'thetext',还有另一个值,例如:'thetext1','thetext2'等等

Is it possible to put inside contains multiple values? I would like to find the divs whic contains: 'thetext', but also another values, for example: 'thetext1', 'thetext2',etc

我想在一个程序中完成它而不是更多:不想使用与我想要找到的文本一样多的程序。

I`d want to make it in one procedure and not in more: dont want to use as many procedures as texts i´d like to find.

谢谢!

推荐答案

您可以使用多重选择器作为条件,例如

You can use the multiple selector as a or condition like

$("div:not(:has(*))").filter(":contains('thetext'), :contains('thetext2')").each(..)

这篇关于Jquery“包含”多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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