87,990
社区成员
发帖
与我相关
我的任务
分享
//数字变色
$(function () {
$(".info .info_content span[class='money']").each(function () {
var str = $(this).html().replace(/([^0-9]+)/gi, '');
var str1 = $(this).html().replace(/([0-9]+)+/gi, '');
var strdiv = "<span style='color:red;font-size:16px;font-family:Adobe 黑体 Std R'>" + str + "</span>" + "<span style='font-size:12px;'>"+str1+"</span>";
$(this).html(strdiv);
});
});
$(function () {
$(".info .info_content span[class='money']").html(function(index, txt){
return txt.replace(/(\d+(?:\.\d+)?)(\D*)/, "<span style='color:red;font-size:16px;font-family:Adobe 黑体 Std R'>$1</span>" + "<span style='font-size:12px;'>$2</span>");
});
});
<script src="jquery.js"></script>
<script>
//数字变色
$(function () {
$("span").each(function () {
$(this).html().replace(/(\d*)\.?(.*)/, '$1 $2');
alert(RegExp.$1);alert(RegExp.$2);
});
});
</script>
<span>100元/月</span>
<span>1.1 元/月</span>
<script src="jquery.js"></script>
<script>
//数字变色
$(function () {
$("span").each(function () {
$(this).html().replace(/(\d*)\.?(.*)/, '$1 $2');
alert(RegExp.$1);alert(RegExp.$2);
$(this).html(strdiv);
});
});
</script>
<span>100元/月</span>
<span>1.1 元/月</span>