2

I want to change text just "24" not "차단".

I used $("#cnt5").text() but it doesn't work.

How to?

<div class="cntBox link" id="cnt5" data-url="recentStat.php" style="cursor: pointer;">
    <span class="cntName">차단</span>
    24
</div>
GoodSea88
  • 145
  • 1
  • 12

1 Answers1

0

Just extract the text and then remove everything but numbers.

// Extract the text
const str = document.getElementById('cnt5').textContent

// Remove everything but numbers
const res = str.replace(/\D+?|([0-9])+?/g, '$1');

console.log(res);
.as-console-row-code {
  color: blue;
  font-size: 64px !important
}
<div class="cntBox link" id="cnt5" data-url="recentStat.php" style="cursor: pointer;">
  <span class="cntName">차단</span> 24
</div>
zer00ne
  • 41,936
  • 6
  • 41
  • 68