jQuery > Traversing methods

.add() - Add element to particular element in jQuery

How to add an element to a particular element in jQuery?


To add an html element to a particular html element, add() method can be used.

 <script>
      $("div").add("p").append(" + This is added - ").css("color", "brown");
  </script>

Above code snippet add a paragraph (p) element to all div element of the page. That paragraph element will have “ + This is added - ” text written in brown color.

 Views: 5110 | Post Order: 39



Write for us






Hosting Recommendations