0

It's been some time since I've used JQuery, so this might be something very obvious.

I am attempting to use JQuery to set the colour of all text inside <span> tags which has a class containing a certain keyword (in this example, the word inside the class tag is "var").

I then put this jQuery code into the body of the document:

$("class*='var'").css("color", "#FF00DC");

But this doesn't make any difference.

Is there a simple syntax error I'm making here or is this something a bit deeper? I've made a jsFiddle to try and illustrate the problem.

Thanks in advance.

2 Answers 2

6

Try:

$("[class*='var']").css("color", "#FF00DC");
Sign up to request clarification or add additional context in comments.

Comments

5

Your selector syntax is wrong, it should be $("[class*='var']") (see attribute contains selector).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.