How to print a pound “£” in html file?

前端 未结 7 1150
再見小時候
再見小時候 2021-01-21 06:43

i am trying to display a pound sign in my html page.i want to display it through a variable because i am getting the values of sign from an xml file.

Here is Code:

7条回答
  •  执笔经年
    2021-01-21 07:12

    You can use \u00A3 ...

    Demo

    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()

    Demo 2

提交回复
热议问题