What does $ ('<div / ">') do?
1 answer
He used to create the div element. Its short abbreviation to <div></div> .
For instance:
$('<div/>', {id: 'hello', 'class': 'new', html: 'New div'}).appendTo('#target'); will create a div with id: hello , class: new using html New div and add to #target .
More details
This means "create a div element wrapped with jQuery on the fly."
If the parameter has a single tag, for example
$('<div />')or$('<a></a>'), jQuery creates the element using its own JavaScriptcreateElement().
As a result, it will look like this:
$(document.createElement("div")); See here for more details.
+12