title: Find last character with jQuery
body: <p>I have an HTML element which can contain plain text or other HTML elements:</p>
  
  <pre><code>&lt;!-- plain text --&gt;
  &lt;div class="content"&gt;
    SIMPLE TEXT.
  &lt;/div&gt;
  
  &lt;!-- or other html elements --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;a&lt;/td&gt;
        &lt;td&gt;b&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;!-- more html elements --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;div&gt;
      OTHER TEXT WITH MORE &lt;span&gt;HTML!&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- one more example --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;div&gt;
      OTHER TEXT WITH MORE &lt;span&gt;HTML&lt;/span&gt;!
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How can I append one more HTML element to the <strong>last printable character</strong> in my <code>.content</code> div, regardless of in which HTML element the character is?</p>
  
  <p>Expected result:</p>
  
  <pre><code>&lt;!-- plain text --&gt;
  &lt;div class="content"&gt;
    SIMPLE TEXT.&lt;span class="end"&gt;&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;!-- or other html elements --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;a&lt;/td&gt;
        &lt;td&gt;b&lt;span class="end"&gt;&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;!-- more html elements --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;div&gt;
      OTHER TEXT WITH MORE &lt;span&gt;HTML!&lt;span class="end"&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- one more example --&gt;
  &lt;div class="content"&gt;
    SIMPLE &lt;span&gt;TEXT.&lt;/span&gt;
    &lt;div&gt;
      OTHER TEXT WITH MORE &lt;span&gt;HTML&lt;/span&gt;!&lt;span class="end"&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>