in jQuery, what is the difference between
$("div")
and$("<div>")
?
$("div")
finds all existing div
elements in the document.
$("<div>")
creates a div
element, which you’d then append to the document at some stage (presumably).
If so, is this the standard way of creating new DOM elements in jQuery, or are there other ways?
Fairly standard, yes. Other ways of creating elements include adding HTML content to any existing element (via append
or html
or before
or insertBefore
or any of a large number of other functions).
solved in jQuery, what is the difference between $(“div”) and $(“
“)?