Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contenteditable issue

In this: http://jsfiddle.net/bLHVh/4/ I have a contenteditable div, and whenever you type in it, it replaces 'a' with 'b', just as a simple example (it will do useful stuff later, of course). It works fine until you hit enter, then the div loses focus after every keystroke. Why is this?

like image 210
penguinrob Avatar asked Nov 13 '22 19:11

penguinrob


1 Answers

try this

$("#area").bind('keypress', function(e){
    if(e.which == 13){
        e.preventDefault();
    }
});
like image 105
momo Avatar answered Dec 22 '22 03:12

momo