In jquery what does $('<div></div>') do?

I was implementing a jqueryui modal dialog box and a related blog showed a way of implementing it that worked but I don't understand what $("<div></div>") is actually doing. Is this creating a blank div element to use? Is this a safe way of implementing this?


It's equivalent to document.createElement('DIV').

You can look at the jQuery source. Look for the comment:

// Handle HTML strings

And you'll see how it works.

The <div> created is empty, has no attributes, and is not attached to the DOM.

It's more common to see it written as:

$('<div />')

...but not functionally different.

Often it's chained with a method like appendTo(), to insert it into the DOM.

Need Your Help

why second time cp command is faster

linux shell

When I execute cp folder1 folder2 -rf,for the first time it takes around 10 mins. But when it I execute the second command cp folder1 folder3 -rf, it takes around 1 min. folder1 contains about 100 ...

Can I Configure m2eclipse through pom.xml?

eclipse maven-2 m2eclipse maven-eclipse-plugin

With the maven-eclipse-plugin, using mvn eclipse:eclipse, you can specifiy eclipse project natures and builders that will automatically be added to the eclipse project.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.