How to prepend text not html in jquery

5
Average: 5 (3 votes)
Reputation: 155
Asked 2 years ago.
374 View(s)
How to prepend text not html in jquery

I realise that I can prepend stuff to an element using:

$(...).prepend(myText);

However, if myText is, let’s say, "<span>", I actually want that text to appear, but .prepend()would instead prepend an empty span element. What is the recommended way to solve this? Do I really have to HTML-escape the text manually or is there something more elegant?

Delivery Time: 3 days.
Question Category: CMS.
Farhan Muhammad
Reputation: 112
Free
Deliver in: 3 days

Tutor Answer

You must be login to view answer.