1
Good afternoon!
I’m inserting into a HTML TAG <p>
some blanks, to complete the number of characters within a certain description (120).
I need the blanks to stay visible on the page.
Down with TAG:
<p class="descricao">Exemplo de texto</p>
But I’m having a problem adding the blanks.
I tried to use character ALT + 255, alias '', but the spaces are not being inserted, I also tried to make use of '
' but it didn’t work.
I did some tests, and when I replace the white character with letters and numbers, it works normally.
Anyone can help?
Follow the code below Javascript that I’m using:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="descricao">Exemplo de texto</p>
<script>
var publicacoes = $( '.descricao' );
for (var i = 0; i < publicacoes.length; i++)
{
var texto = publicacoes[i].textContent;
var textoComplementar = " ";
for (var j = 0; j < (120 - texto.length); j++)
{
texto += textoComplementar;
}
publicacoes[i].textContent = texto;
}
</script>
Thanks for the answer Pedro, the problem is that I need white spaces to be visualized in HTML, that’s why I was talking about the special characters.
– João Greco