jQuery > Manipulations methods

.before() - Place content before element in jQuery

How to place content before a specific element in jQuery?


To place content before a specific html element, before() method can be used.

 <script>
      $("h1").before("<h2>This should not be at the top</h2>");
  </script>

Above code snippet will place the specified text (<h2>This should not be at the top</h2>) before “h1” element of the web page.

 Views: 5967 | Post Order: 49



Write for us






Hosting Recommendations