How To Print A Pound "£" In Html File?
Solution 1:
You can use \u00A3
...
Alternatively you can use entity name as £
or entity number as £
as well but you need to use .html()
and NOT.text()
And use var
and not Var
As you commented, I see you are getting more troubles with this, if you want you can accomplish this easily with CSS like
#monthly_amt:before {
content: "'£'"; /* Or you can use \00a3 instead of £ */
}
And your jQuery will be
var monthlypayment = 1000;
$('#monthly_amt').text(monthlypayment);
And if the element is dynamically generated, you can get rid of it using .remove()
Solution 2:
It is:
£
or
£
You can check other encodings here:
http://www.w3schools.com/html/html_entities.asp
And here is a demo on how to do it: Online Demo
var sign = "£";
$('#demo').html(sign+124.5);
Solution 3:
To print a pound symbol, simply ... print the pound symbol:
var sign = '£';
$('#monthly_Amt').text(sign + monthlypayment);
Or, if that's somehow uncomfortable:
var sign = "\u00A3";
$('#monthly_Amt').text(sign + monthlypayment);
Or, with the quotes:
$('#monthly_Amt').text("'" + sign + "'" + monthlypayment);
Update
It seems that the "variable" actually comes from an HTML element, but \x00A3
only works in string literals.
This HTML fixes it:
<divid="currencySign">£</div>
Solution 4:
Try this one,
£ £££ Pound Sterling
See this Link
http://webdesign.about.com/od/localization/l/blhtmlcodes-cur.htm
Solution 5:
Try using:
var sign = '£'
$('#monthly_Amt').html("\'"+sign+"\'"+monthlypayment);
For the £ sign use: £ (ASCII Code)
http://jsfiddle.net/seckela/7gjF5/
EDIT: Using .text() will render the literal text, .html interprets it as an HTML element and will render special ASCII Characters using the ASCII codes.
Post a Comment for "How To Print A Pound "£" In Html File?"