On onclick I am getting Uncaught ReferenceError: akkiTooltip is not defined.
Check the code that I am using:
$(document).ready(function () {
function akkiTooltip() {
function applyTooltip(element, word) {
var tooltipText = $('' + element + ' label').data('tooltip');
var newContent = $('' + element + ' label').html().replace(word, '<span data-tooltip="' + tooltipText + '">' + word + '</span>');
$('' + element + ' label').removeAttr('data-tooltip');
return $('' + element + ' label').html(newContent);
}
applyTooltip('#question_307', 'Some text');
}
});
This is from another js file where I am applying onclick:
$(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();');
After moving akkiTooltip function outside $(document).ready function, I am getting this error
Uncaught TypeError: Cannot read property 'replace' of undefined