In jQuery, an inbuilt method andself() is defined to add the previous set of elements to the current set. It will keeps the previous elements to the current set and maintain it in the internal stack. That the internal stack will take responsible of changes to the matched set of elements.

Syntax of andself() Method

andself() (selector)

Here, it doesn’t accept any parameter and it returns all added element against the specified selector.

Example Script


        $(document).ready(function() {




In the latest version, it won’t work perfectly. Instead of using this, you can try addback() method. Here as follows;

Example of jQuery addback()
  <meta charset="utf-8">
  <title>addBack demo</title>
  p, div {
    margin: 5px;
    padding: 5px;
  .border {
    border: 2px solid red;
  .background {
    background: yellow;
  .left, .right {
    width: 45%;
    float: left;
  .right {
    margin-left: 3%;
  <script src=""></script>
<div class="left">
  <p><strong>Before <code>addBack()


First Paragraph


Second Paragraph


After addBack()


First Paragraph


Second Paragraph


Leave a Reply

Your email address will not be published. Required fields are marked *