JSFiddle - React, Tailwind, and code Playground
by bluey
HTML
<div> <!--Chat Text window -->
<span>Welcome to chat. Be good. Be nice. Be drunk!</span>
<div id='textflow' style='height: 400px; width: 80%;'>
<div class='msg'>
</div>
</div>
</div>
<textarea id='inputchat' class='chatinput' placeholder='Type here and hit enter...' style='width: 60%;'></textarea>
<input type='text' id='username' class='nameinput' placeholder='Type your Username here...' style='width: 60%;'/>
<button class='inputChat' type='submit'>Send!</button>
JavaScript
$(function(){
$('.inputChat').click(function() {
//get input data
message = $('#inputchat').val();
username = $('#username').val();
// $.get( "chattext.php", function( data ) {
//write to window
$( "#textflow" ).append("<"+ username +"> "+message+"<br />");
// });
//clear input
$('#inputchat').val('');
});
$.ajax({
type: "POST",
url: "updatechat.php",
data: newinput,
cache: false,
success: function(result){
// alert(result);
}
});
});