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());
精彩评论