Reputation: 79
I've the following script in my HTML:
jQuery.sundayMorning(text, { destination: 'en' }, function(response) {
var uri = response.translation;
var text = decodeURIComponent(uri);
jQuery(".showText").val(text);
});
Example input in Spanish: la casa de leo el combatiente
.
This translates into English as: leo's house fighter
.
I want to show this as: leo's house fighter
.
Anyone knows a way to solve this?
Upvotes: 1
Views: 232
Reputation: 1109172
Normally, you would use the element.html()
function for this. But since you're using val()
, you'll be trying to show it in an input element instead of some div. Input elements doesn't support the html()
function. Since there's no direct API available in jQuery to decode HTML/XML entities, you'd like to create a div element, use its html()
and then get the result as text()
.
var decodedText = jQuery("<div/>").html(encodedText).text();
Then you can show this in the input element.
jQuery(".showText").val(decodedText);
Upvotes: 1