I’m working on a budget app that lets the user write in their budget and as many expenses as the user wishes.
The total budget, expenses, and balance (each of these is a span tag in HTML) are kept in a container div.
I want to add a dollar sign next to each of these spans. How do I add a dollar sign that sits right next to the amount? I need to make it a separate tag from the money tags.
I tried adding it in the form of a template string such as
amount.innerHTML = `$${tempAmount}`
expenditureValue.innerText = `$${sum};
However, doing this results in messing up with numbers adding together. Adding more than one expense results in "NaN" appearing on the page.
I also tried adding it into the HTML page, but the dollar sign is skewed from the number result. It ends up looking like:
$
10000
Any advice on what I can do?
2
Answers
Provided you have a class for the element, or the ability to add a class, you can always add a pseudo-element and set its content using CSS.
Please try to add the symbol code. I think it make your code easier.