JacobTheDev
JacobTheDev

Reputation: 18520

Scan for Class Name on Page

I need to search an entire web page for class="error", and if it doesn't exist, change error = true to error = false.

How can I do this with jQuery? I have a vague feeling I can do it with .each(); somehow, but I'm not sure how to go about it.

Upvotes: 0

Views: 77

Answers (1)

VisioN
VisioN

Reputation: 145408

This is the shortest way:

var error = $(".error").length > 0;

Upvotes: 8

Related Questions