jQuery > Attribute related method

.prependTo() - prepend content to target element in jQuery

How to insert html content from source element to the beginning of target in jQuery?


To insert html content of the source element to the beginning of the target element, prependTo() method can be used.

<script>
      $("p").prependTo("#div2");
  </script>

Above code snippet will write all paragraph elements of the page before the element whose id is “div2".

 Views: 4642 | Post Order: 33



Write for us






Hosting Recommendations