What can I use in jquery instead of document.createTextNode(' ')
js line.
I'm trying to do sth like this :
js : divButtons.appendChild(document.createTextNode(' '));
jquery : $("#divButtons").append(?????);
createTextNode() Creates a new Text node. This method can be used to escape HTML characters.
HTML DOM Document createTextNode()Attributes are nodes. Texts are nodes. Some elements contain other nodes. Some elements contain text nodes. Some elements consain attribute nodes.
The HTML DOM createTextNode() method is used to create a Text Node with the specified text.
Please be careful with the existing answers. They show how to append HTML. HTML is not Text. Treating text as HTML is a) a bug and b) dangerous.
Here is a sane solution:
$('selector').append(document.createTextNode('text < and > not & html!'))
This is using jQuery only for the append part. Nothing wrong with using createTextNode. jQuery uses createTextNode internally in its text(str)
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With