Open In App
Related Articles

How to append a jQuery object to all paragraphs using jQuery ?

Like Article
Save Article
Report issue

In this article, we will see how to append a jQuery object to all paragraphs using jQuery. Append means we add something to an existing element. The object is used to define a container for an external resource like a page, a picture, a media player, or a plug-in application.

Used Methods:

  • ready() Method: This method is used to specify a function to execute when the DOM is fully loaded.
  • click() Method: This method is used to trigger the click event, or attaches a function to run when a click event occurs.
  • append() Method: This method is used to insert specified content at the end of the selected elements.


  • Create the HTML page with paragraph <p> elements.
  • Next, write a script to append the object to the paragraph element.

Example: In this example, we are using the above-explained approach.


<!DOCTYPE html>
    <script src=
        body {
            text-align: center;
            font-size: 20px;
        button {
            background-color: #4CAF50;
            /* Green */
            border: none;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
        object {
            font-size: 30px;
            color: lightgreen;
            background-color: green;
        $(document).ready(function () {
            $("button").click(function () {
                    "<object>This is object</object>.");
    <h2 style="color:green">GeeksforGeeks</h2>
        Click on the button to append object
        at the end of every paragraph.
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <button>Append Object</button>



Append object

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 05 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Similar Reads
Complete Tutorials