I have written the following code that aims to create a div and within it a nested span. Here is the code. Its results buffle me:
function(){
$("<div>", {
text: "<span>SomeText</span>",
class: "queryTitle"
}).prependTo(container);
When inspected in chrome this is the resulting html:
<div class="queryTitle"><span>1234</span></div>
And while this is the exact html I am aiming for, this html is not rendered properly in the browser, as the span block displays "unrendered" in the browser, like below:
<span>1234</span>
(I understand I can rewrite the code like below
function(){
$("<div class = " + queryTitle + "><span>1234</span></div>").prependTo(container)
}
which returns the desired result, yet I find this syntax a bit unreadable, plus I would really like to understand what I am doing wrong as an educational drill.
Thank you for reading.