将oninput与CodeMirror一起使用
Using oninput with CodeMirror
当我的文本区域只是一个文本区域时,oninput正在启动我的函数。既然我已经将文本区域转换为CodeMirror,我就无法注册console.log()。
这就是我使用CodeMirror 的方式
var editor = CodeMirror.fromTextArea(document.getElementById("textArea"), {
mode: "javascript",
lineNumbers: true,
lineWrapping: true,
theme : 'monokai'
});
这是具有输入功能的文本区域
<textarea id="textArea" oninput="return myKeyPress(event)"></textarea>
这是我的函数,应该由oninput 调用
function myKeyPress(e) {
socket.emit('textAreaText', document.getElementById('textArea').value);
console.log("first emit");
}
当文本区域收到输入时,如何运行此函数?
我不确定这是否是你想要的,但这对我有效,我评论了套接字,因为我无法在fiddle上定义它:
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("textArea"), {
mode: "javascript",
lineNumbers: true,
lineWrapping: true,
theme : 'monokai'
});
function myKeyPress(e){
//socket.emit('textAreaText', document.getElementById('textArea').value);
console.log("first emit");
}
</script>
<textarea id="textArea" oninput="return myKeyPress(event)"></textarea>
这里的小提琴
相关文章:
- 转义符不能与innerHTML一起使用
- 高亮显示与数组字符串一起使用时文本插件中断
- setTimeout可以与闭包内的函数一起使用吗
- 将依赖外部库的UMD模块与browserfy捆绑在一起
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- 如何将js库与typescript一起使用
- 将webpack和babel与父项目目录中的文件一起使用
- 将 Drag&Drop 与 jsTree 和 DataTables 一起使用
- Javascript-如何让脚本与Ajax请求的数据一起运行
- 将两个ext.TabPanels滚动到一起
- 将jQuery UI Timepicker Addon与React一起使用
- 什么是curl以及如何将其与nodejs一起使用
- Javascript”;onmousemove”;事件无法与类一起使用
- 将require('..')与变量一起使用与在webpack中使用字符串相比
- 如何在php中创建一个函数,该函数与文本区域一起工作,通过输入类似[color:red]的内容来打印具有等效颜色的文本
- 三角库可以与firefox一起使用,但不能在Chrome中使用
- 为什么不't我的ruby代码与javascript文件一起插入
- 通过jQueryAjax一起发布Array和Form数据时出现问题
- 如何将eventListeners与Angularjs+Electron一起使用
- 将oninput与CodeMirror一起使用