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?

有帮助吗?

解决方案

Use .hasClass()

The Syntax is

$(selector).hasClass(classname)

其他提示

Just use hasClass();

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

ie...

  if($('#mydiv').hasClass('testClass')){  //YOUR CODE HERE if TRUE }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top