rashadb rashadb - 17 days ago 7
HTML Question

Can you bold a number variable in a string and express it the UI when placed in the html?

I have the following situation:

Javascript:

var aNumber = 17;
var problem = "Is there a way to bold a number like this: "+aNumber+"?";


HTML:

<ion-item>{{problem}}</ion-item>


I get:
Is there a way to bold a number like this: 17?

I want:
Is there a way to bold a number like this: 17?

I've tried using
<b></b>
and
<strong></strong>
within the problem variable around the variable aNumber.

This looked like:

var problem = "Is there a way to bold a number like this: "<strong>+aNumber+</strong>"?";


No that didn't work either.

I also tried the following:

var aNumber = 17;
var problem = "Is there a way to bold a number like this: "


HTML:

<ion-item>{{problem}}{{aNumber}}?</ion-item>


This answer only shows the problem variable:
Is there a way to bold a number like this:

Answer

Not sure about <ion-item> but according to the tag mentioned in the problem, do it like this:

var aNumber = 17;
var problem = "Is there a way to bold a number like this: <strong>" + aNumber + "</strong>?";

document.getElementById('output').innerHTML = problem;
<div id="output"></div>