ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

I can't find element by id

Open pouyali opened this issue 1 year ago • 3 comments

📝 Ask a question

How can I find an element by id? I have access to the editor instance. what method should I use? I want to replace it's content with another text.

pouyali avatar Nov 14 '24 06:11 pouyali

Suggested solution is to use the setData().

Here is guide about it: https://ckeditor.com/docs/ckeditor5/latest/getting-started/setup/getting-and-setting-data.html#replacing-the-editor-data-with-setdata

pszczesniak avatar Nov 14 '24 06:11 pszczesniak

Hi, thanks for the quick response. I have a button that needs to find an element by it's id, but for some reason hasAttribute('id') is always false. and getAttribute('id') is also always null when I use getAttributes() it's returning objects like htmlPAttributes and ... inside them if I go further I can find the id. but not directly

pouyali avatar Nov 14 '24 06:11 pouyali

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot avatar Nov 14 '25 23:11 CKEditorBot

We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

CKEditorBot avatar Dec 15 '25 23:12 CKEditorBot