简体   繁体   中英

Javascript: adding bold text dynamically within paragraph

I'm trying to append a text to web page and some of it as bold dynamically through Javascript. But the bold text moves to new line and not within same line. I would like it to be at same line. Here is the output:

在此处输入图片说明

在此处输入图片说明

My code is:

var paraNode = document.createElement('p');
paraNode.className = "card card-body";
var textToAppend = " Passenger Revenue for " + month + " " + year + ": " + String(totalValue).bold();
paraNode.innerHTML = textToAppend
notebookElement.appendChild(paraNode)

I have also tried using <strong> tag replacing .bold() but the result is same.

I tried and looks fine I think CSS could be the Issue.

 var paraNode = document.createElement('p'); paraNode.className = "card card-body"; var textToAppend = " Passenger Revenue for " + String("34").bold(); paraNode.innerHTML = textToAppend document.body.appendChild(paraNode) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM