How would I select a div ID with a specific class and then move that class to the next ID with jQuery/javascript? -


i have code:

<div class="m-item m-active"> </div>  <div class="m-item"> </div>  <div class="m-item"> </div> 

what want when click button, jquery finds div class of "m-item" has class of "m-active", removes "m-active" class div , moves next "m-item" div.

so after clicking button, code should (where m-active on second div):

<div class="m-item"> </div>  <div class="m-item m-active"> </div>  <div class="m-item"> </div> 

does know how can done?

thank you.

$('.m-active').removeclass('m-active').next('.m-item').addclass('m-active'); 

further reading:

next(), addclass(), removeclass()


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -