$.extend($.expr[":"], { exactly: function( element, index, details, collection ){ return $(element).text() === details[3]; } }); $("div:exactly(Foo)").addClass("red"); $("div:exactly(230)").addClass("blu");
<div>Foo</div> <div>Not Foo</div> <div>230</div> <div>230,000</div>
.red { color: red; } .blu { color: blue; }