0

This is my HTML code

 <input id="email" name="email" type="text" autocomplete="off" />
 <span id="emailInfo"></span>

This jQuery script which validates the input and prints a message within the span tags

 emailInfo.text("This email is already registered!");

This works prefect but when I try to print an HTML entity, it won't be recognized.

 emailInfo.text("&#x2713;");

&#x2713; = ✓

However, It would be recognized if I manually typed it anywhere in the HTML page.

Why is this happening ?

1 Answer 1

2

You have to switch from text() to html(), as jQuery's text() method does not parse the string as HTML, but inserts it as text, hence the entities won't be converted.

emailInfo.html("&#x2713;");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.