JQuery Adding multiple classes to a div tag

I would like to obtain the next line of code using JQuery:

<div class="something something_else">
</div>

I use $(document.createElement('div')); to create the div, but then how do I add something and something_else to the div?

I'm sure it's something basic, but I can't seem to figure it out.

Answers


Try this:

$('<div/>', {"class": "something something_else" })

Need Your Help

Why does Android Eclipse constantly refresh external folders and take forver?

android eclipse performance refresh

Just my a new Android phone and I've been tinkering with some basic apps. It's been driving my crazy that the Android plugin for Eclipse refreshes externals folders whenever I save ANYTHING. Normal...

django ModelMultipleChoiceField (default values)

python django forms

I've been searching and trying to get this to work for the past few hours and I can't

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.