Using jQuery, I am capturing the text input of a form using .val()
:
$newItem = $('input[type=text]').val();
The problem is that .val()
will preserve any html-tags, which will be applied in the DOM if I am appending the variable.
What is the recommended, safe way to escape HTML-input and just use the text value?