Insert newline on enter key in contenteditable div

后端 未结 3 1746
独厮守ぢ
独厮守ぢ 2021-01-18 23:53

I am trying to insert a newline character instead of whatever the browser wants to insert when I press enter in a contenteditable div.

My current code looks somethin

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-19 00:41

    something like this?

    if(e.which==13){
        e.preventDefault();
        $('#divID').html($('#divID').text()+"
    "); }

提交回复
热议问题