Is there a built-in jQuery function to encode a string as HTML?

Is there a built-in jQuery function to encode a string as HTML?

I am trying to take the text that the user enters into a text box, and then puts that text in another area of ​​the page. My plan was to take .val()from a text field and pass it to an element .html()element <div>. Perhaps there is a good jQuery plugin to help with this (if it's not built-in) or a better way to achieve this.

For example, if a user places <Victory!>in a text box, I would like the other part of the page to actually display text <Victory!>, and not anything visible.

+3
source share
2 answers
+3

.val() HTML (.. ), , .html(). - ? html-?

0

Source: https://habr.com/ru/post/1743420/


All Articles