Changing CSS classes when different strings are displayed in a text element with jQuery

Posted by Nick Maddren on Programmers See other posts from Programmers or by Nick Maddren
Published on 2014-08-22T17:02:53Z Indexed on 2014/08/22 22:32 UTC
Read the original article Hit count: 390

Filed under:
|
|

I'm just wondering if this method would be possible using jQuery HTML and PHP.

Basically I have a filtering system were products are listed, some have different attribute values such as Hatchback for example.

The text element that holds these PHP echo's also have a css class that implements an icon.

I'm just wondering can I alter class's that are added to a html element just by looking at the string?

So for example if the string displays "Pick-up" then jQuery alters the class and adds the one associated with the "Pick-up" string?

Thanks sorry if this is a little confusing, I can explain more if needed.

© Programmers or respective owner

Related posts about JavaScript

Related posts about css