I have a Javascript function to format numbers with thousands seperator. I have many Span tags with the same class in my HTML code and I want to apply to all of them.
<span class="money">here is the number</span>
<script type="text/javascript">
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
</script>
How can I apply the Javascript on every span with this class?