There are various method to create HTML element inside an HTML document using JQuery. But the simplest of all is append() and prepend() method.
Method 1: Using prepend() Method: The prepend() method is used to insert a specified content at the beginning of the selected element.
Example: This example uses prepend() method to create div element at the beginning of selected element.
Method 2: Using appendTo() Method: The appendTo() method in jQuery is used to insert HTML element at the end of the selected element.
Example 1: This example uses appendTo() method to create div element at the end of selected element.
Example 2: This example uses appendTo() method to create div element within the div element.
- jQuery | Create a div element
- How to create hidden form element on the fly using jQuery ?
- How to create To-Do List using jQuery?
- Create a Tic-Tac-Toe Game using jQuery
- How to create UI Datepicker using jQuery ?
- How to remove parent element except its child element using jQuery ?
- How to create a jQuery plugin with methods?
- How to create followspot effect using HTML CSS and jQuery ?
- How to create a CSS rule or class at runtime using jQuery ?
- How to Create a Custom Image Magnifier using jQuery ?
- How to create slide left and right toggle effect using jQuery?
- How to create responsive image gallery using HTML, CSS, jQuery and Bootstrap?
- jQuery | Move an element into another element
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Shivam_k