Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

I've been able to get this jQuery working in jFiddle:

  function addCommas(nStr)   {   nStr += '';   x = nStr.split('.');   x1 = x[0];   x2 = x.length > 1 ? '.' + x[1] : '';   var rgx = /(\d+)(\d{3})/;   while (rgx.test(x1)) {   x1 = x1.replace(rgx, '$1' + ',' + '$2');   } return x1 + x2;   } $(function(){ $(".format").each(function(c, obj){ $(obj).text(addCommas(parseFloat($(obj).text()).toFixed(2))); }); }); 

But I can't seem to get it going on the wordpress site I'm working on. I'm playing around with jQuery.noConflict();jQuery.noConflict();, but honestly I'm pretty confused.

I've been able to get this jQuery working in jFiddle:

  function addCommas(nStr)   {   nStr += '';   x = nStr.split('.');   x1 = x[0];   x2 = x.length > 1 ? '.' + x[1] : '';   var rgx = /(\d+)(\d{3})/;   while (rgx.test(x1)) {   x1 = x1.replace(rgx, '$1' + ',' + '$2');   } return x1 + x2;   } $(function(){ $(".format").each(function(c, obj){ $(obj).text(addCommas(parseFloat($(obj).text()).toFixed(2))); }); }); 

But I can't seem to get it going on the wordpress site I'm working on. I'm playing around with jQuery.noConflict();, but honestly I'm pretty confused.

I've been able to get this jQuery working in jFiddle:

 function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } $(function(){ $(".format").each(function(c, obj){ $(obj).text(addCommas(parseFloat($(obj).text()).toFixed(2))); }); }); 

But I can't seem to get it going on the wordpress site I'm working on. I'm playing around with jQuery.noConflict();, but honestly I'm pretty confused.

Source Link

I've been able to get this jQuery working in jFiddle:

 function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } $(function(){ $(".format").each(function(c, obj){ $(obj).text(addCommas(parseFloat($(obj).text()).toFixed(2))); }); }); 

But I can't seem to get it going on the wordpress site I'm working on. I'm playing around with jQuery.noConflict();, but honestly I'm pretty confused.