Reputation: 13
Date format for a field displays as "January 1 , 2000" (for example).
I would like to remove the extra space before the comma using jQuery. I tried this but it does not seem to work:
$('.field-item:contains(" , ")').html().replace(' ,' , ',');
Upvotes: 1
Views: 220
Reputation: 13194
You change value that is returned but you do not assing it back to item. Use:
var field = $('.field-item:contains(" , ")');
var newValue = field.html().replace(' ,' , ',');
field.html( newValue ); //assing it back
So it's working like (http://api.jquery.com/html/)
item.html(); //returns value
item.html(newVal); //changes value
Upvotes: 1