问题描述
- html 回车键默认程序是什么?
-
如题,在html元素contenteditable = “true”属性下,敲入回车会自动换行,请问各位大神回车键执行的默认代码是什么?在哪里能找到?
解决方案
默认代码???你是指n?问题描述的清楚些吧~~
解决方案二:
keydown,keyup,keypress事件,通过事件对象的keyCode可以判断按下的什么键,回车keyCode是13
<div style="border:solid 1px #000;height:200px;width:300px" contenteditable="true" onkeydown="keydown(event)">
</div>
<script>
function keydown(e) {
alert(e.keyCode)
if (e.keyCode == 13) {
alert('按下了回车')
}
}
</script>
时间: 2024-08-17 13:06:19