input 이나 textarea 에 적용할 수 있다.
.html file
<p contenteditable="true">
Element is editable
</p>
<p contenteditable="false">
Element is NOT editable
</p>
<p contenteditable="inherit">
Element inherits its parent's editable status
</p>
.js file
var content = document.querySelector('[contenteditable]');
// 1. Listen for changes of the contenteditable element
content.addEventListener('input', function(event) {
// 2. Retrive the text from inside the element
console.log(content.innerHTML)
})
태그 안에 contenteditable="true"를 심어주면 됨