Sachin
Sachin

Reputation: 13

Bold only a part of string in javascript

Im displaying a message on a webpage in this format "5 pencils will be given to 6 students".

"span style="" data-bind="text: app.summary()"/span" 

Knock out databind is used here. summary() is a js method which returns me this message in the format defined in message.js file as "{0} pencils will be given to {1} students" but i need to display only the numbers as bold in the final HTML page.

I.e.5 pencils will be given to 6 students. I don't want to create individual span and split the string message.

Is there any way to do that?

Thanks

Upvotes: 0

Views: 1581

Answers (1)

Yabada
Yabada

Reputation: 1758

"<strong>{0}</strong> pencils will be given to <strong>{1}</strong> students"

Upvotes: 3

Related Questions