0

Help me with this

function applyFormatting(style) { const selection = window.getSelection(); if (selection.toString().trim() !== '') { document.execCommand(style, false, null); } } boldBtn.addEventListener('click', () => applyFormatting('bold')); italicBtn.addEventListener('click', () => applyFormatting('italic')); underlineBtn.addEventListener('click', () => applyFormatting('underline')); fontSelect.addEventListener('change', () => { const font = fontSelect.value; editor.style.fontFamily = font; }); fontSizeInput.addEventListener('change', () => { const fontSize = fontSizeInput.value + 'px'; editor.style.fontSize = fontSize; }); colorPicker.addEventListener('change', () => { const color = colorPicker.value; editor.style.color = color; });

13th Jul 2024, 4:25 PM
Dekev
3 Answers
+ 1
document.execCommand() is deprecated, you will have to find other way to achieve something similar to what was allowed by that method. https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
9th Sep 2024, 4:17 PM
Ipang
0
i was trying to make a text editor with html css and js
2nd Sep 2024, 10:41 AM
Dekev