开发者

How do I make a word bold in javascript?

I am using javascript to populate data in a table which return everything fine. I would like to make a string bold. See cod开发者_如何学Pythone below

$tr.find('.data').val($('#txtName').val() + '  <strong>Address:<\/strong> ' + $('#txtAddress').val());

How do I make only the word "Address" bold?


If .data is a form input element or a textarea, you cannot make it bold without turning it into a Rich Text area, which requires a lot of additional code files (via a plugin normally) and setup.

If .data is just a td or div, etc, then .val() is the wrong way to set the content. If you just use .html() the bold will come through, provided it hasn't been overridden in the CSS. Also, you don't need to escape the forward slash:

$tr.find('.data').html($('#txtName').val() + '  <strong>Address:</strong> ' + $('#txtAddress').val());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜