How to create an HTML element using jQuery ? Last Updated : 09 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to create an HTML element using jQuery. To create and append the HTML element, we use the jQuery append() method. The jQuery append() method is used to insert some content at the end of the selected elements. Syntax: $(selector).append( content, function(index, html) ) Parameters: content: It is a required parameter and is used to specify the content which is to be inserted at the end of selected elements. The possible value of contents is HTML elements, jQuery objects, and DOM elements.function(index, html): It is an optional parameter and is used to specify the function that will return the content to be inserted.index: It is used to return the index position of the element.html: It is used to return the current HTML of the selected element. Example: In this example, we will use the append() method of JQuery. HTML <!DOCTYPE html> <html> <head> <title> How to create an HTML element using jQuery? </title> <script src=" https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <!-- Script to add div element in the HTML document --> <script> $(document).ready(function() { $("button").click(function() { $(".append").append( '<div class="added">New HTML element added</div>'); }); }); </script> <!-- Style to use on div element --> <style> .added { padding: 20px; margin-top: 20px; background: green; color: white; display: inline-block; } </style> </head> <body> <center> <h1 style="color: green;">GeeksforGeeks</h1> <h3> How to create an HTML element using jQuery? </h3> <button id="append">Append New HTML Element</button> <div class="append"></div> </center> </body> </html> Output: Comment More infoAdvertise with us Next Article How to create a div element in jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads How to Create an Image Element using JavaScript? Creating an image element dynamically using JavaScript is a useful technique when you want to add images to a webpage without having to manually write the <img> tag in your HTML. This allows for more flexibility, as we can create and manipulate images based on user interactions or other condit 2 min read How to create a div element in jQuery ? 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 2 min read Create a Div Element using jQuery In this article, we will see how to create a <div> element using jQuery. We can create a div element with the following steps: Steps to Create a Div ElementCreate a new <div> element.Choose a parent element, where to put this newly created element.Put the created div element into the par 2 min read How to attach a method to HTML element event using jQuery ? In this article, we are going to learn, how can we attach a method to an HTML element event using jQuery.There are various events like click(), mouseenter(), mouseout(), etc which are available in jQuery. For attaching a method to an HTML elements event, we will need a jQuery method on(), which will 2 min read How to Add Attributes to an HTML Element in jQuery? To add attributes to an HTML element in jQuery, the attr() method can be used. This allows to set one or more attributes for a selected element, such as id, class, src, and href.Approach: Given an HTML document containing <label>, <input>, and <button> elements. The <input> e 1 min read How to get the outer html of an element using jQuery ? Sometimes, there is a need to get the entire HTML element by its id and not merely its contents, for doing so, we shall use the HTML DOM outerHTML Property to get the outer HTML of HTML element. Syntax: document.getElementById("your-element-id").outerHTML) You can use a variable and initialize it to 2 min read Like