title: Uncaught ReferenceError: is not defined onclick
body: <p>On onclick I am getting <code>Uncaught ReferenceError: akkiTooltip is not defined</code>.<br>
  Check the code that I am using:</p>
  
  <pre><code>$(document).ready(function () {
      function akkiTooltip() {
          function applyTooltip(element, word) {
              var tooltipText = $('' + element + ' label').data('tooltip');
              var newContent = $('' + element + ' label').html().replace(word, '&lt;span data-tooltip="' + tooltipText + '"&gt;' + word + '&lt;/span&gt;');
              $('' + element + ' label').removeAttr('data-tooltip');
              return $('' + element + ' label').html(newContent);
          }
          applyTooltip('#question_307', 'Some text');
      }
  });
  </code></pre>
  
  <p>This is from another js file where I am applying onclick:</p>
  
  <pre><code>$(button)
      .text(this.answers[a].title)
      .attr('type', 'button')
      .attr('class', 'btn')
      .attr('onclick', 'quiz._makeSelection(\'answer_' + this.answers[a].id + '\', ' + go + ', ' + this.answers[a].skipToSection + '); akkiTooltip();');
  </code></pre>
  
  <hr>
  
  <p>After moving <code>akkiTooltip</code> function outside <code>$(document).ready</code> function, I am getting this error</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'replace' of undefined
  </code></pre>