In a contenteditable element, When pressing the enter key, I am trying to detect if the line where I press enter is an li tag.
I did the following code which works fine in Firefox and chrome :
$("div[contenteditable=true]").on('keydown', function(e) {
if( e.keyCode === 13 ) {
if (window.getSelection) {
var node = document.getSelection().anchorNode;
var nodeName = node.parentNode.nodeName.toLowerCase();
if(nodeName == 'li') {
console.log(" I am an <li> ");
}
}
}
I am wondering how to do that with Internet explorer ?