Question

i have a html like this:

<td class="TableDetail1 itemNumber">1</td>
<td class="TableDetail1 itemNumber">2</td>
<td class="TableDetail1 itemNumber">3</td>

how to use replace to match the pattern above and change the 1/2/3 numbering? my javascript look like this:

 x.innerHTML = x.innerHTML.replace(/<td class="TableDetail1 itemNumber">+document.getElementsByClassName('itemNumber')[lastRow].innerHTML+<\/td>/g,  '<td class="TableDetail1 itemNumber">'+numbering+'</td>');

but it did not work.

Was it helpful?

Solution

i come out a solution with this:

 x.innerHTML = x.innerHTML.replace('<td class="TableDetail1 itemNumber">'+currentRow+'</td>',  '<td class="TableDetail1 itemNumber">'+numbering+'</td>');

this seem work..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top