$("div:contains(' 1434')").parent().addClass('date');
class is added to ALL divs. I know, class/id would help but the html is tag soup and I can do nothing about it. Is there any way to restrict the match to just the element that contains the text directly?
You can use
hasto get the parent elements, andnotto get the innermost elements:Demo: http://jsfiddle.net/Guffa/JFHjG/