Apply javascript function to an html element
20:02 28 Nov 2012

Sorry for the noob question but I am trying to apply this javascript function to data in an html table. The function comes from this Stack Overflow post.

function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

I wish to apply this function to something like this:

5000 5600

with the hopes of returning 5,000 next to 5,600. I can't figure out this simple thing. I know I need to use an id or class on one of the tags and that this needs to match something in the function so I tried

5000 5600

to no avail. I'm sure the function works given the amount of upvotes.

Can a kind soul please walk me through the steps to make this work? I've googled all over for a basic tutorial and haven't found anything.

javascript number-formatting