JSFiddle - React, Tailwind, and code Playground
by lchau
HTML
<ol contenteditable>
<li>Press enter</li>
</ol>
JavaScript
var list = document.querySelector('ol');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
var list_values = [].slice.call(list.children)
.map(function(node) {
return node.innerHTML;
})
.filter(function(s) {
if (s === '<br>' || s === "<br />") {
return false;
} else {
return true;
}
});
}
console.log(list_values);
});
});
observer.observe(list, {
attributes: true,
childList: true,
characterData: true
});