Skip to content

Instantly share code, notes, and snippets.

@siamkreative
Created March 28, 2016 03:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siamkreative/d4e7abe544e18bd1fd9c to your computer and use it in GitHub Desktop.
Save siamkreative/d4e7abe544e18bd1fd9c to your computer and use it in GitHub Desktop.
Check if a TinyMCE editor is empty in WordPress
jQuery(document).ready(function ($) {
// Check if TinyMCE is active
if (typeof tinyMCE != "undefined") {
$('form').on('submit', function () {
// Get content of active editor
var editorContent = tinyMCE.activeEditor.getContent();
if ((editorContent === '' || editorContent === null)) {
// Do stuff when TinyMCE is empty
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment