Hi all,
I’m trying to put the result of an ajax call in bold…
ex the AJAX call return
var zone = object.zone;
I want this zone be in bold, in the sentence
result.textContent = ‘At’ + zone + ‘there is a lot of water’;
I’m searching since yesterday…
Thanks a lot for your help !
Is textContent
HTML? If so, then I think
'At <b>' + zone + '</b> there is a lot of water'
will work
Thanks for your comment, but no, the sentence is on javascript, so "< b> " is on the screen when i do that (sorry i’m french, i don’t know if i speak well…)
Are you working on codepen? Maybe you can show it?
(and don’t worry about your English )
About this line,
var resultatElt = document.getElementById('resultat');
there isn’t any element in your HTML with an id of resultat
.
Also, textContent
renders strings as is (so tags like <b>
will be printed as is and not get interpreted as HTML tags). You may want to use innerHTML
instead.
Yes, i did it on sublime text because i do my tests on sublime and after un put all in codepen, in my mind it’s easier, but in sublime text i put this.
I made the change on codepen you can see it now
Just change textContent
to innerHTML
and use the string I made in my first post. That should work.
1 Like
YES ! It works !
Thanks a lot