I want to make a simple console terminal using stdin and stdout. Basically I have a function that inputs something and retrieves something to the chat.
As you know it would say something like [email protected]:/ and then I can type ONLY in that line. When I press enter/submit it would appear another line with [email protected]:/ for me to type again.
How do I make this to be able to type only in the last line and in front of the [email protected]:/ (basically this is locked)?
Any better ideas to implement this instead of textarea??
$('#btnSubmit').click(function() { var terminal = $('#terminal'); var stdin = terminal.val(); console.log(stdin); //Get stdout (FAKE FOR THE EXAMPLE) terminal.append(stdout() + '<br>'); }); function stdout(stdin) { return "[email protected]:/" } .terminal { background-color: #000; color: #fff } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <textarea class="terminal" rows="20" id="terminal"></textarea> <button class="btn btn-primary" id="btnSubmit" type="button">Send</button>
textareaelement without it returning the tags as inline strings.divthat has thecontenteditableattribute? And then add your desired elements there.