jquery - Extra linebreak in contenteditable after focus() -
in chrome/safari jsfiddle test http://jsfiddle.net/ylqqe/
if type 'hi' , press enter, text appears first in red box, moves blue one.
but, if type 'hi', click outside of box blur()
it, click on text , hit enter, space.
why space showing up? how can prevent happening?
that's easy fix. return false
after logic return key, default action doesn't take place:
$(document).keydown(function(e){ switch(e.keycode) { case 13: $('#msg').append(newel.html()); newel.html('') return false; } });
Comments
Post a Comment