title: Get the count of words in TinyMCE with Word Count plugin
body: <p>I wanna get the count of words in the textarea and make changes to my users account based on the number of words.  For example: a person writes 1000 words and its credibility goes up in the account 
      (I use Django)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"&gt;&lt;/script&gt;
  
      &lt;script&gt;
        tinymce.init({
          selector: "textarea",  // change this value according to your HTML
          plugins: "wordcount",
          toolbar: "wordcount"
        });
  </code></pre>
  
  <p>I Use this But I got an error : <code>TypeError: tinymce.activeEditor is null</code></p>
  
  <pre><code>var wordcount = tinymce.activeEditor.plugins.wordcount;
  
  console.log(wordcount.body.getWordCount());
  console.log(wordcount.body.getCharacterCount());
  console.log(wordcount.body.getCharacterCountWithoutSpaces());
  
  console.log(wordcount.selection.getWordCount());
  console.log(wordcount.selection.getCharacterCount());
  console.log(wordcount.selection.getCharacterCountWithoutSpaces());
  </code></pre>
  
  <p>**</p>
  
  <pre><code>  &lt;/head&gt;
  
    &lt;body myFunction()&gt;
      &lt;form method="post"&gt;
        &lt;textarea id="mytextarea"&gt;&lt;/textarea&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  
      enter code here
  </code></pre>