On jQuery, I'm looking to a similar selector to :contains
but I need to do a perfect match against an element text. Is there any?
<div>1</div>
<div>12</div>
<div>13</div>
<div>135</div>
so If I look for text = 1
I would only get the first div
You can make one:
$.extend($.expr[":"], {
exactly: function( element, index, details, collection ){
return $(element).text() === details[3];
}
});
$("div:exactly(Foo)").addClass("red");
$("div:exactly(230)").addClass("blu");
Fiddle: http://jsfiddle.net/jonathansampson/YUQLF/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With