Pregunta

I would like to check whether the particular sytle / class has already been applied on given element.

What is the correct jQuery function to check this?

¿Fue útil?

Solución

Use .hasClass()

The Syntax is

$(selector).hasClass(classname)

Otros consejos

Just use hasClass();

$('#mydiv').hasClass('testClass');

ie...

  if($('#mydiv').hasClass('testClass')){  //YOUR CODE HERE if TRUE }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top