1

I have a div:

<div id="pageMessagesBox"></div>

In a java script function I am trying to add some items inside my div:

$("#pageMessagesBox").html("<a id='id'></a>");

But I've got the following result for $("#pageMessagesBox").html():

"<A id=id></A>"

The expected is:

"<A id='id'></A>"

What am I doing wrong here ?

2
  • 1
    The HTML you get back is generated from the DOM, and as such, browser dependent. Commented Apr 25, 2011 at 11:33
  • 1
    You're not doing anything wrong here. This output is expected and will function correctly. Commented Apr 25, 2011 at 11:34

1 Answer 1

4

From jquery documentation

This method uses the browser's innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document. For example, Internet Explorer sometimes leaves off the quotes around attribute values if they contain only alphanumeric characters.

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.