Jarred
Jarred

Reputation: 2024

Using HTML Escape Characters in Javascript

I am using jQuery to change the value of a button. The button contains arrow quotes (« and »). When I type the them in the javascript file it shows the character codes, not the characters themselves.

How do I get these arrow quotes to display properly within javascript?

Upvotes: 0

Views: 823

Answers (2)

Álvaro González
Álvaro González

Reputation: 146660

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript"><!--
jQuery(function($){
    $("input:button").val("«Done» and <Done>");
});
//--></script>
</head>
<body>

<p><input type="button" value="Please wait..."></p>

</body>
</html>

(If I wanted to display their codes, I'd have to think on how to do it.)

Upvotes: 1

SavoryBytes
SavoryBytes

Reputation: 36256

How are you setting it? This works for me

<button id="test"></button>

$('#test').html('&#171');

Upvotes: 0

Related Questions