I want to replace the class name with just the id clicked. But the condition is, there is the beginning of the class name ("filter-") I want to change.
For example:
<div class="change filter-" id="changeMe"></div>
<div class="list">
<div class="click" id="first"></div>
<div class="click" id="second"></div>
<div class="click" id="third"></div>
</div>
When you click #first
then filter-
must be filter-first
like this:
<div class="change filter-first"></div>
It can normally be done with addClass
and removeClass
. But is there a way to do this with regex?