How to select all anchor tags with specific text

后端 未结 6 1634
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 20:21

Given multiple anchor tags:

My Text

How do I select the anchors matching the class and wi

6条回答
  •  猫巷女王i
    2020-12-12 20:54

    You could create a custom selector similar to :contains for exact matches:

    $.expr[':'].containsexactly = function(obj, index, meta, stack) 
    {  
        return $(obj).text() === meta[3];
    }; 
    
    var myAs = $("a.myclass:containsexactly('My Text')");
    

提交回复
热议问题