javascript - jquery - append html doesn't append the empty String inside the div -
i doing chat project in java.
using server response through jquery-ajax , creating html , append html div.
my jquery - html alert without empty string-name(note id='user' in alert) ,

after appending in chat area ,

after jquery-html alert with empty string-name(note id='user' in alert) ,

after appending in chat area ,

my jquery creating html ,
function send(name , message , time){ //name = $("#name").val(); //message = $("#message").val(); var user = "<div id='user' class='fontstyle'>"+name+"</div>"; var msg = "<div id='msg' class='fontstyle'>"+message+"</div>"; var timestamp = "<div id='time' class='fontstyle'>"+time+"</div>"; var row = "<div id='msgset' >"+ user + msg + timestamp +"</div>"; alert(row); return row; } there no empty string present in chat area.
hope our stack members me.
you can escape html string keeps white spaces. see details here.
or can trim message string (=remove spaces @ beginning , end of it) such instruction, , manualy add spaces (with code inside div, span, ...):
s.replace(/\s+/g, ' ');
Comments
Post a Comment