javascriptjqueryuser-interfacewebjquery-append

JQuery append filters out html like tags?


I would like to append below line of text to the select html tag using JQuery:

"<option selected=true value="-1"><new></option>"

The problem is in <new>. This substring is filtered out completely by append function. I know this is not legal html tag, and probably it filters it just of this reason. Can I force JQuery somehow to interpret <new> as substring? Because <new> is not meant as html tag, but only to point out to the user that this is not the value in the list, but a selection to make a new entry on the list.


Solution

  • take a look at this post : How to display HTML tags as plain text

    it shows you how to print special characters like < and > in between your code.

    you should replace < by &lt; and > by &gt;