Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>The jQuery Example</title>
- <!-- jQuery Library -->
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- // Change background color of all <p> elements
- $("p").css("background-color", "yellow");
- // Reading HTML content of an element
- let content = $("#myid").html();
- console.log("Content of #myid:", content);
- // Writing HTML content to an element
- $(".myclass").html("Updated paragraph content using jQuery.");
- });
- </script>
- </head>
- <body>
- <div>
- <!-- Paragraph with class "myclass" -->
- <p class="myclass">This is a paragraph.</p>
- <!-- Paragraph with id "myid" -->
- <p id="myid">This is second paragraph.</p>
- <!-- General Paragraph -->
- <p>This is third paragraph.</p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement