jquery 截取字符串的实现
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=gb2312' /> <title>需要F5刷新一下</title> <script src='http://img.jb51.net/jslib/jquery/jquery-1.3.2.min.js' type='text/javascript'></script> <style> *{ margin:0; padding:0;font-family:'宋体',Arial, Helvetica, sans-serif;} #best{ width:300px; height:200px; border:1px solid #ccc; margin:60px auto 0; line-height:1.6; font-size:14px; padding:10px 0 0 10px} .blank{ font-size:18px; font-weight:bold; text-align:center; padding:20px} </style> </head> <body> 需要F5刷新一下 <table> <tr id='generated_rows'> <td class='row_class' id='row_id_1'>1</td> <td class='row_class' id='row_id_2'>2</td> <td class='row_class' id='row_id_3'>3</td> <td class='row_class' id='row_id_4'>4</td> <td class='row_class' id='row_id_5'>5</td> </tr> </table> <script type="text/javascript"> $('#generated_rows td.row_class').each(function() { var x = Number($(this).text()).toFixed(2); $(this).text(x); }); </script> </body> </html>