Wednesday, December 15, 2010

jQuery hasClassName prototypejs function: How to check if element has class with JQuery

To determine if an element has a class register with jQuery you can use the function .hasClass() which is shorter for .hasClassName() in prototypejs



if($('#target').hasClass('foo')){
// Do something
}

// With Prototype js you would use...

if($('target').hasClassName('foo')){
// Do something
}