title: jQuery and google maps auto complete
body: <p>I have Google Maps Autocomplete working on several<code>input</code> tags like this:</p>
  
  <pre><code> &lt;input class="controls pac-input" id="pac-input" type="text" onfocus="geolocate()" placeholder="Type custom address" /&gt;
  </code></pre>
  
  <p>To enable Google Maps auto-complete, I have the following code:</p>
  
  <pre><code>//https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform
  $(document).ready(function () {
  
      autocomplete = new google.maps.places.Autocomplete((document.getElementById('pac-input')), { types: ['geocode'] });
  
      google.maps.event.addListener(autocomplete, 'place_changed', function () {
          MyFunc();
      });
  
  });
  </code></pre>
  
  <p>And then, in the <code>MyFunc()</code> function I do what I need:</p>
  
  <pre><code>function MyFunc() {
      var fullAddress = autocomplete.getPlace().formatted_address;
      var input = $(this);
      //stuff that uses input
  }
  </code></pre>
  
  <p>This code however, has two problems:</p>
  
  <ul>
  <li>The first is that i am using an Id, to affect multiple input boxes (I have many input fields). I tried selecting by class but it fails with error ´undefined´. How can I apply that function to a collection of input fields?</li>
  <li>How do I know which field is being clicked? I tried using the jquery <code>$(this)</code> but it aint working. How can jQuery help me ?</li>
  </ul>
  
  <p>Thanks in advance!</p>