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.

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

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: 1082 | Post Order: 39

Write for us