Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX
Created November 20, 2014 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaNdTriX/2c057e1c219a4a5f32a9 to your computer and use it in GitHub Desktop.
Save HaNdTriX/2c057e1c219a4a5f32a9 to your computer and use it in GitHub Desktop.
Checks if an element is contentEditable
/**
* Checks if an element is editable.
* Does this by checking parent
* elements as well.
*
* @param {Node} targetNode
* @return {Boolean}
*/
function isContentEditable(targetNode){
while(targetNode.parentElement){
if(targetNode.contentEditable === 'false'){
return false;
}else if(targetNode.contentEditable === 'true'){
return true;
}else{
targetNode = targetNode.parentElement;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment