Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Click on header to add another header in jQuery ?

  • Last Updated : 25 Mar, 2021

In this article, we will see how to add a new header element after clicking the existing header elements in jQuery. To add the new header element, the delegate() method is used.


$(selector).delegate("Selected_elements", function() {

Here, we use delegate() method to add one or more event handlers to the specified element that are children of selected elements. Also, we use after() method to insert content, specified by the parameter for each selected element in the set of matched element.



<!DOCTYPE html>
        How to Click on header to add
        another header in jQuery?
    <script src=
        $(document).ready(function () {
            $("body").delegate("h1, h3", "click", function () {
                $(this).after("<h4>Added Another Header!</h4>");
        body {
            text-align: center;
        h1 {
            color: green;
        How to Click on header to add
        another header in jQuery?


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!