how to preserve element after button is clicked

i was trying to add element while button is clicked.but it is added when i click on button and it is gone just in 2 minutes.so how to set permenantly.following is code i tried.

$(document).ready(function() {
  var d = "";
  $("input[name='submit']").click(function() {
    alert("button is clicked");
    d = $("select").val();
    alert("d====" + d);
    myfunction(d);
  });

  function myfunction(d) {
    if (d != "" && d != "undefined" && d != null) {
      for (i = 0; i < d; i++) {
        alert("hello");
        var d1 = "<div class='form-group'><label>Upload Image</label><div class='input-group'><span class='input-group-addon'><i class='fa fa-picture-o'></i></span><input type='file' name=" + i + "class='form-control' placeholder='Upload your photo' id='img'></div></div>";
        $("#d2").append(d1);
      }
    }
  }
});

Answers 1

  • sorry I put submit button inside form element while clicking button it is post and page is loaded(refresh) and content is disabled....that's the reason.


Related Articles