Last active
October 26, 2017 16:48
-
-
Save atomize/abc47a2df45070983ccf3924d0a78409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<ol contenteditable oninput=""> | |
<li>Press enter</li> | |
</ol> | |
<script> | |
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
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>') { | |
return false; | |
} | |
else { | |
return true; | |
} | |
}); | |
console.log(list_values); | |
} | |
}); | |
}); | |
observer.observe(list, { | |
attributes: true, | |
childList: true, | |
characterData: true | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
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>') { | |
return false; | |
} | |
else { | |
return true; | |
} | |
}); | |
console.log(list_values); | |
} | |
}); | |
}); | |
observer.observe(list, { | |
attributes: true, | |
childList: true, | |
characterData: true | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment