我使用内联Ckeditor
来编辑内容。默认情况下,双击带有 contenteditable="true"
的 div
即可激活内联编辑器。我想在单击一个按钮时激活此内联编辑器,并在单击另一个按钮时隐藏它。
以下是 html 代码示例:
<html>
<head>
<script src="ckeditor/ckeditor.js"></script>
</head>
<body>
<div id="first" contenteditable="true">first</div>
<div id="second" contenteditable="true">second</div>
<input type="button" value="show inline editor">
<input type="button" value="hide inline editor">
</body>
</html>
Jsfiddle 显示了默认行为和我想要的 http://jsfiddle.net/vdRYL/
最佳答案
我们可以隐藏和显示工具栏。我使用以下方式实现了此功能:
打开ckeditor.js
文件。并将以下代码粘贴到文件末尾
$(document).ready(function () {
CKEDITOR.on('instanceReady', function (ev) {
document.getElementById(ev.editor.id + '_top').style.display = 'none';
ev.editor.on('focus', function (e) {
document.getElementById(ev.editor.id + '_top').style.display = 'block';
});
ev.editor.on('blur', function (e) {
document.getElementById(ev.editor.id + '_top').style.display = 'none';
});
});
});
关于javascript - Cckeditor:按需显示和隐藏内联工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20448416/