It is not a miracle, when you pass
<div></div> to jQuery it matches it against the regular expression and tag check conditions like below
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 // Assume that strings that start and end with <> are HTML and skip the regex check match = [ null, selector, null ]; }
else matches it with below regular expressions to find out the element in the selector string.
Once it find the element, then jQuery uses
document.createElement("stripped Tag from selector") and will return the element with necessary jQuery methods added.
I would say until and unless you need it for your requirement, use
document.createElement('div') instead of
JQuery creates an element but it doesn't add it to DOM automatically. I order to see it in the DOM you have to add it to DOM you could use $().after, $().appendTo and so on...