var str='Hello World'; var tooltipHtml = '<b>' + str + '</b>'; $('#tooltip').html(tooltipHtml); The result in the #tooltip container is the word Hello World. But if
var str='<h1>Hello World</h1>'; The result will be
Hello world
but<h1>Hello World</h1> is an example, the tags will be different in different situations, how to fill a container (in this example tooltip) and html and text at the same time? Can somehow escape all tags in str?The second option that can occur is when
var str='Hello World'; var tooltipHtml = '<b>' + str + '<span class="error">Часть недоступна</span></b>'; $('#tooltip').html(tooltipHtml);