结果中不显示串联的空格

结果中不显示串联的空格

本文介绍了结果中不显示串联的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的填充没有正确连接,即空白未显示。不知道为什么它没有显示出来并且已经花了两个小时来调整代码而看不到解决方案。

The padding I want is not properly concatenating, i.e. the white spaces are not showing up. Not sure why it isn't showing up and have been at it for a couple hours tweaking the code with no solution in sight.

var padWord = function(word){
    if(endsInPunctuation(word)){
        trueLength = (word.length)-1;
    }else{
        trueLength = word.length;
    }
    switch(trueLength){
        case 1:
            word = "   " + word.fontcolor("red");
            break;
        case 2:
            word = "  " + word.replaceAt(1, word.charAt(1), "red");
            break;
        case 3:
            word = "  " + word.replaceAt(1, word.charAt(1), "red");
            break;


推荐答案

浏览器默认折叠多个空格字符。使用不间断空格& nbsp; 或CSS white-space:pre; 或html标签< pre>

Browsers collapse more than one whitespace character by default. Use nonbreaking spaces &nbsp; or css white-space:pre; or the html tag <pre>

这篇关于结果中不显示串联的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:04