title: how to run a specific function with several ID's
body: <p>I have a php page that includes 5 php files. in each of the files, I put an input[button] for each php file, when the user click on it, the function will be fired.
  As I'm not allowed to use same ID in the page, I'm getting confused to apply     $(document).ready(function(){..}) for each ID. How can I handle it?
  More clearly:
  I have ('#add_more1,#add_more2,#add_more3,#add_more4,#add_more5). What I want is when the user click on each of those ID's, it fires the code below.
  for example if he click on ('#add_more2') , it will run the code
  thank's in advanced.</p>
  
  <pre><code> //  To add new input file field dynamically, on click of "Add More Files" button below function will be executed.
  $('#add_more2').click(function() {
      $('#show2').append($("&lt;div/&gt;", {
          id: 'filediv'
      }).fadeIn('slow').append($("&lt;input/&gt;", {
          name: 'file[]',
          type: 'file',
          id: 'file'
      })));
  });
  // Following function will executes on change event of file input to select different file.
  $('body').on('change', '#file', function() {
      if (this.files &amp;&amp; this.files[0]) {
          counter += 1; // Incrementing global variable by 1. 
          $(this).before("&lt;div id='abcd" + counter + "' class='abcd'&gt;&lt;img id='previewimg" + counter + "' src=''/&gt;&lt;/div&gt;");
          var reader = new FileReader();
          reader.onload = imageIsLoaded;
          reader.readAsDataURL(this.files[0]);
          $(this).hide();
          $("#abcd" + counter).append($("&lt;i/&gt;", {
              id: 'img',
              top:0,
              class: 'fa fa-times',
              alt: 'delete'
          }).click(function() {
              $(this).parent().parent().remove();
          }));
      }
  });
  // To Preview Image
  function imageIsLoaded(e) {
      $('#previewimg' + counter).attr('src', e.target.result);
  };
  $('#upload').click(function(e) {
      var name = $(":file").val();
      if (!name) {
          alert("First Image Must Be Selected");
          e.preventDefault();
      }
  });
  </code></pre>