html - adding a class to an anchor based on specific text in that anchor jquery -
new jquery , appreciate help.
my markup looks this:
<dl> <dt>colors</dt> <dd><a>red</a></dd> <dd><a>green</a></dd> <dd><a>blue</a></dd> </dl>
let's wanted add specific class anchor text "green". how go that?
thanks
the :contains selector return partial matches green
match green
, lightgreen
or darkgreen
, of times choice use .filter()
$('dl a').filter(function(){ return $.trim($(this).text()) == 'green' }).addclass('newclass')
Comments
Post a Comment