首页 > 技术文章 > jQuery 价格显示 前面位数与后面两位显示不同样式(一大一小)

arealy 2017-11-01 11:30 原文

<!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>

  

 

推荐阅读