开发者

Select element based on text

开发者 https://www.devze.com 2023-01-05 18:22 出处:网络
I want to select an element based on their innertext in JQ开发者_Go百科uery. Below is my Html <html>

I want to select an element based on their innertext in JQ开发者_Go百科uery. Below is my Html

<html>
    <body> 
        <a href="fddf">4</a> 
        <a href="fddf">4</a> 
        <a href="fddf">4</a> 
    </body> 
</html>

I want to select all the <a> tags which has text of "4". Any idea how do I do it?


You're looking for the :contains selector, like this:

$('a:contains("4")')


I think the correct way is $("a[outerText='4']"). Contains returns 4,44,444 etc. .

0

精彩评论

暂无评论...
验证码 换一张
取 消