Created
November 20, 2014 14:05
-
-
Save HaNdTriX/2c057e1c219a4a5f32a9 to your computer and use it in GitHub Desktop.
Checks if an element is contentEditable
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
/** | |
* 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