Skip to content
Advertisement

How to add style to the matching string of text?

I have got the list of elements like this:

JavaScript

Textlink is: ANONFILE, GOFILE, MEGA

With Javascript/JQuery/CSS, Is there anyway I can check textlink and could simply only change the element’s CSS if the inner Textlink equals:

  • IF textlink equal “ANONFILE” style css
JavaScript
  • IF textlink equal “GOFILE” style css
JavaScript
  • IF textlink equal “MEGA” style css
JavaScript

The only way I know to do this is to get all of the links and loop through them checking to see if the textlink contains the string I am searching for.

Is there a better way to do this without change original code?

Advertisement

Answer

You could write the classes in CSS, then add the .textContents as a class, like this:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement