如果按下按钮,如何使用 ckeditor 显示警报?
代码如下:
$(document).ready(function () {
$(".cke_button__bold").click(function () {
editor.on("CKEDITOR.cke_button__bold",CKEDITOR.cke_button_on);
function handleAfterCommandExec(evt){
var commandName = CKEDITOR.command.cke_button__bold;
// For 'bold' commmand
if (commandName == 'cke_button__on')
{
alert("Bold button pressed!");
}
}
});
});
最佳答案
event delegation
Event delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future.
$(document).ready(function () {
$(document).on('click','.cke_button__bold',function () {
if($(this).hasClass('cke_button_on'))//checking for enable only
{
alert("Click event occure when only enable");
}
});
});
关于javascript - 在 CK 编辑器中单击按钮时显示警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27372292/