-1

I want to append the text <b>text</b> to an element as a child without changing it into HTML.

append('<b>text</b>') gives bold content text, but I want the text to be <b>text</b>.

Ovilia
  • 7,066
  • 12
  • 47
  • 70

2 Answers2

3

Append a text node:

.append(document.createTextNode('<b>text</b>'));
David Hellsing
  • 106,495
  • 44
  • 176
  • 212
0

You have to mix up native js to accomplish this,

var node = document.createTextNode("<b>test</b>");
$('element')[0].appendChild(node);

DEMO

Balachandran
  • 9,567
  • 1
  • 16
  • 26