0

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.

000
  • 26,951
  • 10
  • 71
  • 101
Teddybugs
  • 1,232
  • 1
  • 12
  • 37

1 Answers1

0

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..

Teddybugs
  • 1,232
  • 1
  • 12
  • 37