Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to work with jQuery appendTo() function

<html>
   <head>
      <title>jQuery appendTo()</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
		
      <script>
         $(document).ready(function() {
            $("div").click(function () {
               $(this).appendTo("#result");
            });
         });
      </script>
		
      <style>
         .div{ 
             margin:10px;
             padding:12px; 
             border:2px solid #666;
             width:60px;
         }
      </style>
   </head>
	
   <body>
      <p>Click on any square below to see the result:</p>
      <p id = "result"> THIS IS TEST </p>
      <hr />
		
      <div class = "div" style = "background-color:blue;"></div>
      <div class = "div" style = "background-color:green;"></div>
      <div class = "div" style = "background-color:red;"></div>
		
   </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.