亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery 截取字符串的實現(xiàn)

 更新時間:2009年06月01日 01:53:03   作者:  
不錯的用jquery實現(xiàn)的,字符串截取功能實現(xiàn)代碼。

[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]


下面是對一些數(shù)字進行格式化
我們想改變這么一段代碼中間td之間的文本
<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>

實現(xiàn)顯示為:

<table>
<tr id='generated_rows'>
<td class='row_class' id='row_id_1'>1.00</td>
<td class='row_class' id='row_id_2'>2.00</td>
<td class='row_class' id='row_id_3'>3.00</td>
<td class='row_class' id='row_id_4'>4.00</td>
<td class='row_class' id='row_id_5'>5.00</td>
</tr>
</table>
實現(xiàn)的函數(shù)為:
$('#generated_rows td.row_class').each(function() {
var x = Number($(this).text()).toFixed(2);
$(this).text(x);
});
演示代碼

[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]

相關(guān)文章

最新評論