JibriI
JibriI

Reputation: 53

jQuery Select only the last class from one element

I have elements with clas="a 1" and "a 2", etc. I want to select the last class. For example in "a 1", select 1 and make it 2. How could I do that?

Upvotes: 0

Views: 29

Answers (1)

Justinas
Justinas

Reputation: 43479

Simply remove class and add required:

$('.a.1').removeClass('1').addClass('2');

Upvotes: 1

Related Questions