The problem is that if I focus on the childOfroot
element and press a key, the element triggered is it's parent yet it is supposed to be itself.
function test(event, element) {
console.log($(element).attr('id'))
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span id="root" contenteditable="true" onkeyup="test(event, this)">
This is changable
<span contenteditable="true" onkeyup="test(event, this)" id="childOfroot"> | including this</span>
</span>
See demo here: https://jsfiddle.net/s36L8bpj/