Mayank Pathak
Mayank Pathak

Reputation: 3681

Jquery : Select a specific class name among multiple classes

I have an element which is annotated with 3 css classes input-small JFilterInput Status. where class name varies except input-small JFilterInput.

I need to select varying class name using some jquery selector.

I tried

var selectedClassName = $(this).attr('class:not(.JFilterInput)');

But it didn't work. How to do this..??

Upvotes: 1

Views: 97

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388436

Try

var selectedClassName = $.trim(this.className.replace(/\b(input-small|JFilterInput)\b/g, ''))

Upvotes: 3

Related Questions