674 posts
  • Has attended an Envato Live event
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Referred between 500 and 999 users
  • Envato Staff
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Support Staff
+7 more
cudazi Staff says

Hello,

I’m looking for a simple alternative to the :contains below since it will match on multiple elements such as “Blog” and “Blog Archive” if in the same UL.menu LI A …

$("UL.menu LI A:contains('Blog')").append('Something...');

Thanks!

41 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
  • United States
timstl says

Do you know for sure what the text will be? If so you can do something like:

$("UL.menu LI A:contains('Blog'), UL.menu LI A:contains('Blog Archive')").append('Something...');

... instead of doing a wild card.

374 posts
  • Bought between 10 and 49 items
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
_rohan says
Hello,

I’m looking for a simple alternative to the :contains below since it will match on multiple elements such as “Blog” and “Blog Archive” if in the same UL.menu LI A …

$("UL.menu LI A:contains('Blog')").append('Something...');
Thanks!
$("UL.menu LI A").each(function(){

  if($(this).html() == "Blog"){
     $(this).append("something");
  }

});
674 posts
  • Has attended an Envato Live event
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Referred between 500 and 999 users
  • Envato Staff
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Support Staff
+7 more
cudazi Staff says

Thanks for the replies – _rohan, your solution works well, thank you!

by
by
by
by
by
by