Featured Post

Jquery hasClass()

.hasClass()
Returns: Boolean
.hasClass(className)
className The class name to search for.
Determine whether any of the matched elements are assigned the given class.
Elements may have more than one class assigned to them. In HTML, this is represented by separating the class names with a space:


The .hasClass() method will return true if the class is assigned to an element, even if other classes also are. For example, given the HTML above, the following will return true:

$('#mydiv').hasClass('foo')
As would:

$('#mydiv').hasClass('bar')
While this would return false:

$('#mydiv').hasClass('quux')
Example Demo
Looks for the paragraph that contains 'selected' as a class.







This paragraph is black and is the first paragraph.


This paragraph is red and is the second paragraph.



First paragraph has selected class:

Second paragraph has selected class:

At least one paragraph has selected class:



Comments

Popular posts from this blog

[Inside AdSense] Understanding your eCPM (effective cost per thousand impress...