Creating a div element in jQuery

How do I create a div element in jQuery?

Text Copied From stackoverflow.com
on : Fri, May 15, 2009 Views : 1463778

Accepted Answer

You can use append (to add at last position of parent) or prepend (to add at fist position of parent):

$('#parent').append('<div>hello</div>');

  
// or $('<div>hello</div>').appendTo('#parent');
 

Alternatively, you can use the .html() or .add() as mentioned in a different answer.

Text Copied From stackoverflow.com
on : Fri, May 15, 2009

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp