Home > DeveloperSection > Forums > JQuery and special characters in attribute
Ashish Pandey

Total Post:128

Posted on    October-07-2013 8:55 AM

 C# C# 

 1 Reply(s)
 1632  View(s)
Rate this:

In my jquery script I need to dynamically translate some content, so part of such function is

$('#password').attr('placeholder', 'Contraseña');

where I tried to change placeholder attribute to text Contraseña.

Unfortunatelly, jquery shows text Contraseña

What does a trick to force jquery to show correct decoded text?

Jeet Verma
Jeet Verma

Total Post:110

Posted on    October-08-2013 1:07 AM

You have to escape special characters using JavaScript syntax, not HTML syntax.

$('#password').attr('placeholder', 'Contrase\u00f1a');

Personally I'd use .prop() instead of .attr() too, though both should work here.

Don't want to miss updates? Please click the below button!

Follow MindStick