I wan to insert some spaces in between two words and I do not want to use pre
tags. In my code here is one input field where user can enter text and some javascript code display it in div
you can check the code right below.
<input type="text" id="user-input" />
<div id="user-text"></div>
Javascript code
$(document).on('keyup', '#user-input', function(event){
var userText = $('#user-text');
var clientText = $(this).val().toUpperCase();
if(event.keyCode === 32 || event.which === 32){ clientText += ' '; }
clientText = $('<textarea />').html(clientText).text();
userText.text(clientText);
});
I'm using
for inserting space between two words but this is not working. It only insert one space if I want to insert ten space then what.
The code is not working like as I'm expecting you can't able to insert more than one space using this code.
UPDATE
I want like this.