替换富文本里的px为rem
var content = '23px' content = content.replace(/(\d+)px/g, function(s, t) { s = s.replace('px', ''); var value = parseInt(s) * 0.001; // 100px = 1rem return value + "rem"; //0.23rem });
var content = '23px' content = content.replace(/(\d+)px/g, function(s, t) { s = s.replace('px', ''); var value = parseInt(s) * 0.001; // 100px = 1rem return value + "rem"; //0.23rem });