Jquery $('id').text With Bold
I have a jquery that changes the text of a link like so: if (urlfind > 0) { $('#linkurl').text('More info'); } And html: I am
Solution 1:
.html()
sets string as HTML content, whereas .text()
sets the string as text.
Write:
if (urlfind > 0) {
$('#linkurl').html('<b>More info</b>');
}
OR
if (urlfind > 0) {
$('#linkurl').html('<strong>More info</strong>');
}
Solution 2:
Or if you wanted to get extravagant (and somewhat unnecessary):
if (urlfind > 0) {
$('#linkurl').css('font-weight', 'bold');
}
Solution 3:
The text()
method inserts text, while the html()
method inserts HTML, and <b>
tags are HTML
if (urlfind > 0) {
$('#linkurl').html('<b>More info</b>');
}
Post a Comment for "Jquery $('id').text With Bold"