Use jquery to determine whether an element contains a specified class instance, jqueryclass
In jquery, two methods can be used to determine whether an element contains a definite class ). The two methods have the same functions.
The two methods are as follows:
1. is ('. classname ')
2. hasClass ('classname ')
The following is an example of whether a div element contains a redColor:
1. Use the is ('. classname') Method
$ ('Div '). is ('. redcolor ')
2. Use the hasClass ('classname') method (note that the earlier version of jquery may be hasClass ('. classname '))
$ ('Div '). hasClass ('redcolor') The following is an example of checking whether an element contains a redColor class. If the element contains a redColor class, the class is changed to blueColor.
<!DOCTYPE html>
In this article, jquery is used to determine whether an element contains a specified class instance. This is all the content shared by Alibaba Cloud. I hope to give you a reference, we also hope that you can support the customer's home.