Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use jquery to convert integers in a table into percentages
How to use jquery to convert integers in a table into percentages

Use jquery to convert the integers in the table into percentages. You can use the global function method replace() to convert the integers into numbers with decimal points. The specific method is as follows:

12 test
3 tests4 tests
56

Replaced code:

$("table tr td").each( function(){

var $td = $(this);

var val = $td.text().replace(/(\d+)/g, "$1% ")

$td.text(val);

});