1. 程式人生 > >jQuery 價格顯示 前面位數與後面兩位顯示不同樣式(一大一小)

jQuery 價格顯示 前面位數與後面兩位顯示不同樣式(一大一小)

20px his 分享 highlight img oct es2017 size rip

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>價格顯示</title>
	<script src="scripts/jquery-1.7.1.min.js"></script>
</head>
<body>
<script type="text/javascript"> 
$(function(){
// 價格顯示
    $(".index_price").each(function(){
        $(this).html(‘<span class="big_price">‘ + $(this).html().split(‘.‘).join(‘.</span><span class="small_price">‘)  + ‘</span>‘);
    });
})
</script> 
<span>¥</span><span class="index_price">987.88</span>
<style>
.big_price {font-size:20px;}
.small_price {font-size:14px;}
</style>
</body>
</html>

  技術分享

jQuery 價格顯示 前面位數與後面兩位顯示不同樣式(一大一小)