Reputation: 1302
Typically I create elements using $("", {}) but I'm running into an issue with certain DOM properties. Any of the properties with camel case, like innerHTML, are set to lower case and then jquery give the elements a custom property. How do I prevent this?
$("p", { "innerHTML" : "<a>text</a>"})
I expect: <p><a>text</a></p>
Instead I get <p innerhtml="<p><a>text</a></p>">
This is true for any property using camel case.
Upvotes: 0
Views: 22
Reputation: 12508
You need to use the jQuery .html()
as the object attribute that you pass in, not the native DOM innerHTML
:
$("<p />", { "html" : "<a>text</a>"}).appendTo('body');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Upvotes: 2