A
A
Alexey2015-05-30 14:33:11
phpstorm
Alexey, 2015-05-30 14:33:11

How to perform a replacement using a regular expression and a counter?

I wanted to change the ID in the HTML file with the increase of each id by 1.
It needs to be like this id="table0", id="table1", id="table2"….
So I didn't find how to do it. I got out of the situation by inserting PHP code with a counter. (table<?=$count++?>).
How to do autocorrect with iterator?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2015-05-30
@IonDen

On jquery:

var counter = 0;

$(elements).each(function () {
    $(this).prop('id', 'table' + counter);
    counter++;
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question