Using "-" in JS File

I have a dropdown that populates a JS file. One of the options in my drop-down list has a - symbol , but instead of showing the letter, it shows this :.

How can I get a form to show a letter -? (something like ascii code, but for JS?)

thanks in advance...

+3
source share
7 answers

First of all, correcting the page encoding (before UTF-8, preferably using <meta http-equiv="content-type" content="text/html; charset=utf-8"/>immediately after <head>) and ensuring that your editor is configured to UTF-8, is usually a very good idea.

Otherwise, replacing - (in JavaScript code, not HTML) is the way to go. \u00f1

JavaScript - HTML XML, &#x00f1; &ntilde;.

+15

UTF-8 , .

HTML ñ ( , ) &#241; &#xF1; ( HTML - JS, ​​ HTML) escape- UTF-8 \u00F1 ( JS).

+2

, . , - <head>:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

, UTF-8, , .

@phihag , , script . , UTF-8 , &ntilde;.

+1
source

Use &ntilde;See here

0
source

Try html object for character

&ntilde;
0
source

You can use character code:

var babyGirl = "ni\u00f1a";
0
source

This is a problem with HTML entities. You need to provide an HTML object instead of a character.

See: http://www.w3schools.com/tags/ref_entities.asp

In particular: & nt ilde; (minus space) → -

-1
source

All Articles