How to disable the enter key from going second line when onpress?

一个人想着一个人 提交于 2019-12-12 05:08:51

问题


I want the enter key to save the data to database, but whenever I press it will break and create second line, I just want it stay at one line

<div id="editable" contentEditable="true">Press enter now</div>

回答1:


This is a jquery solution.

$('input').on('keypress', function(e){
if(e.keyCode == 13){
    e.preventDefault();
}

});



来源:https://stackoverflow.com/questions/16954446/how-to-disable-the-enter-key-from-going-second-line-when-onpress

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!