Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要回车键将数据保存到数据库,但是每当我按下它就会中断并创建第二行,我只想让它保持在一行
<div id="editable" contentEditable="true">Press enter now</div>
这是一个 jquery 解决方案。
$('input').on('keypress', function(e){ if(e.keyCode == 13){ e.preventDefault(); }
});