당신이 에디터의 컨텐츠가 준비되면 리스너를 부착하고, 삭제 또는 백 스페이스를 눌러 확인하고 마지막으로 삭제 된 내용을 얻을 수 있습니다, 예를 들어 그것은 마법처럼 작품처럼 ::
CKEDITOR.replace('your-editor', {
...,
on: {
contentDom: function() { //editor content ready
var myEditor = this;
//add listener
this.editable().attachListener(editor, 'key', function(evt) {
//if delete or backspace pressed
if ((evt.data.keyCode in { 8: 1, 46: 1 })) {
//get the last element
var lastElement = myEditor.elementPath().lastElement,
lastElementName = lastElement.getName(),
lastElementNode = lastElement.$; //native DOM object
//see what properties the node has
console.log(lastElementNode);
//you can use getAttribute to fetch specific attr
//for example, for img element's src attribute
console.log(lastElementNode.getAttribute("src"));
}
});
}
}
});
bro.But 내가 원하는 수 또한 이미지를 삭제할 때 그 세부 정보를 얻지 못합니다. 내 이미지 태그 값은 '
' –
입니다. ** lastElementNode ** 값은 everyTime에서 null입니다. –
@MariSelvan이 http://jsfiddle.net/0Lkvq69f/4/를 확인하십시오. 잘 작동합니다. –