---
title: "JQuery and special characters in attribute"  
description: "JQuery and special characters in attribute"  
author: "Anonymous User"  
published: 2013-10-07  
updated: 2013-10-08  
canonical: https://www.mindstick.com/forum/1649/jquery-and-special-characters-in-attribute  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# JQuery and special characters in attribute

In my jquery [script](https://www.mindstick.com/interview/477/how-can-i-execute-a-php-script-using-command-line) I need to dynamically [translate](https://www.mindstick.com/interview/1732/how-to-translate-in-android) some [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand), so part of such [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) is

```
$('#password').attr('placeholder', 'Contrase&ntilde;a');
```

where I tried to change [placeholder](https://www.mindstick.com/forum/1519/how-do-i-remove-a-listbox-new-item-placeholder) [attribute](https://www.mindstick.com/blog/221/attributes-reflection) to [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) Contraseña.

Unfortunatelly, jquery [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) text Contrase&[amp](https://www.mindstick.com/forum/156207/what-is-amp);ntilde;a

What does a trick to force jquery to show correct decoded text?

## Replies

### Reply by Anonymous User

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.


---

Original Source: https://www.mindstick.com/forum/1649/jquery-and-special-characters-in-attribute

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
