Reputation: 25
Apologies in advance if I am not asking the question properly out of a complete lack of experience in this language. I have a query that returns weather data (works fine). All that I want to do is set certain formatting HTML elements such as bold/italic/underline.
In the below piece of code, I would like Location, Conditions and Visibility to be BOLD. Is there a way to do what I want within the code block below?
$('.weather ul').append(
$('<li />', {
text: 'Location: ' + Location + ' Conditions: ' + weathernow + ', Visibility: ' + visibility_mi
})
);
Current Output: Location: Chicopee, MA Conditions: Clear, Visibility: 10.0m
Desired Output: Location: Chicopee, MA Conditions: Clear, Visibility: 10.0m
EDIT: I should have mentioned I have already attempted adding the <B>
tag in various places where I thought it would go, but it is not working for me. It shows the <B>
as if it were text.
Attempt:
$('.weather ul').append(
$('<li />', {
text: '<b>Location: </b>' + Location + ' Conditions: ' + weathernow + ', Visibility: ' + visibility_mi
})
);
Result: Location: Chicopee, MA Conditions: Clear, Visibility: 10.0mi
Upvotes: 0
Views: 95
Reputation: 208012
Change:
text: 'Location: ' + Location + ' Conditions: ' + weathernow + ', Visibility: ' + visibility_mi
to:
html: '<b>Location:</b> ' + Location + ' <b>Conditions:</b> ' + weathernow + ', <b>Visibility:</b> ' + visibility_mi
Using text:
, you cannot add HTML tags. So, as you can see, I've changed it to html:
and added the <b>
tags around the text that should show as bold.
Upvotes: 3