Advertisement
vvccs

wt_4_jquery

Oct 13th, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>The jQuery Example</title>
  7.     <!-- jQuery Library -->
  8.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  9.     <script type="text/javascript">
  10.         $(document).ready(function() {
  11.             // Change background color of all <p> elements
  12.             $("p").css("background-color", "yellow");
  13.  
  14.             // Reading HTML content of an element
  15.             let content = $("#myid").html();
  16.             console.log("Content of #myid:", content);
  17.  
  18.             // Writing HTML content to an element
  19.             $(".myclass").html("Updated paragraph content using jQuery.");
  20.         });
  21.     </script>
  22. </head>
  23. <body>
  24.     <div>
  25.         <!-- Paragraph with class "myclass" -->
  26.         <p class="myclass">This is a paragraph.</p>
  27.        
  28.         <!-- Paragraph with id "myid" -->
  29.         <p id="myid">This is second paragraph.</p>
  30.        
  31.         <!-- General Paragraph -->
  32.         <p>This is third paragraph.</p>
  33.     </div>
  34. </body>
  35. </html>
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement