Question: I have this code

```
<div></div>
<form>
<input type="text" name="abc">
<input type="submit" value="send">
</form>

$('form').on('submit', function(){
   $.post('process.php', $(this).serialize(), function(data) {
    $('div').html(data);
   });
   return false;
});

```

Everything works but after submit value that I filled into input is gone and it's empty..Where can be problem?

Answer: 
You'll have to provide a custom implementation. 

I would do something like this :

```
function Class() {
    Class.instances.push(this);
};
Class.prototype.destroy = function () {
    var i = 0;
    while (Class.instances[i] !== this) { i++; }
    Class.instances.splice(i, 1);
};
Class.instances = [];

var c = new Class();
Class.instances.length; // 1
c.destroy();
Class.instances.length; // 0

```

Or like this :

```
function Class() {};
Class.instances = [];
Class.create = function () {
    var inst = new this();
    this.instances.push(inst);
    return inst;
};
Class.destroy = function (inst) {
    var i = 0;
    while (Class.instances[i] !== inst) { i++; }
    Class.instances.splice(i, 1);
};

var c = Class.create();
Class.instances.length; // 1
Class.destroy(c);
Class.instances.length; // 0

```

Then you could loop through all instances like so :

```
Class.each = function (fn) {
    var i = 0, 
        l = this.instances.length;
    for (; i < l; i++) {
        if (fn(this.instances[i], i) === false) { break; }
    }
};

Class.each(function (instance, i) {
    // do something with this instance
    // return false to break the loop
});

```
You'll need to store a list of instances yourself:

```
function someClass(param) {

  // add to all
  if (this.constructor.all === undefined) {
    this.constructor.all = [this];
  } else {
    this.constructor.all.push(this);
  }

  // set param
  this.logParam = function() { console.log(param); };
}

var instance1 = new someClass(1);
var instance2 = new someClass(2);

for (var i = 0; i < someClass.all.length; i++) {
  someClass.all[i].logParam();
}

```

If memory leaks are a concern then you can create a method for deleting instances when you are done with them:

```
function someClass(param) {

  ...

  this.destroy = function() {
    var all = this.constructor.all;
    if (all.indexOf(this) !== -1) {
      all.splice(all.indexOf(this), 1);
    }
    delete this;
  }
}

```