Akram Shahda
Akram Shahda

Reputation: 14771

JQuery: html() is not working as expected

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 ?

Upvotes: 1

Views: 127

Answers (1)

suhair
suhair

Reputation: 10929

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.

Upvotes: 4

Related Questions