So, I have a script where you need to go through the P tag in the parent DIV with the entry-content class name and translate each of them using the Google translation API.
Therefore, when the user clicks the link to translate the page from English into Spanish, this function is launched:
function spanish() { $(".entry-content p").each(function(){ var text = $(this).html(); google.language.detect(text, function(result) { google.language.translate(text, "en", "es", function(result) { if (result.translation) { alert($(this).html());
The problem is that iIget for the inner function $(this).html() returns NULL, and I cannot change the current html elements to change it to the new translated text.
So, I think, my question is: How do I pass the currently selected item to nested functions?
thanks
Jamie source share