Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

How to append some text to all paragraphs using jQuery ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In this article, we will append some text to all paragraph elements using jQuery. To append some text to all paragraph elements, we use append() and document.createTextNode() methods.

jQuery append() method is used to insert some content at the end of the selected elements.

Syntax:

$(selector).append( content, function(index, html) )

Example:

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
  
    <!-- Import jQuery cdn library -->
    <script src=
    </script>
  
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("p").append(document
                .createTextNode(" GeeksforGeeks"));
            });
        });
    </script>
</head>
  
<body style="text-align: center;">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <h3>
        How to append some text to
        all paragraphs using jQuery?
    </h3>
  
    <p>
        Computer Science Portal
    </p>
  
    <p>Welcome</p>
  
    <button>Click Here!</button>
</body>
  
</html>


Output:

Before Click the Button:

After Click Button:


My Personal Notes arrow_drop_up
Last Updated : 31 Dec, 2020
Like Article
Save Article
Similar Reads
Related Tutorials