title: Accessing object from HTML?
body: <pre><code>myObject { div: htmlElement, foo1: bar1, foo2: bar2 }
  </code></pre>
  
  <p>Key <code>div</code> is <em>original</em> key and it contains the <code>HTML</code> of this object.</p>
  
  <p>Is it possible to access/get/set <code>myObject</code> and other values: <code>foo1</code> and <code>foo2</code> when I have <code>htmlElement</code> in scope, <em>e.g</em> clicked it?</p>
  
  <p><code>myObject</code> is prototype and I wouldn't mind making prototype getter/setter but I don't know how to access object with/through <code>HTML</code> element.</p>
  
  <hr>
  
  <p><strong>Making an object:</strong> don't mind <em>Google Maps part</em>, it's just a normal object..</p>
  
  <pre><code>function customHTML(latlng, foo, map) {
      this.latlng = latlng;
      this.foo = foo;
      this.setMap(map);   
  }
  customHTML.prototype = new google.maps.OverlayView();
  
  customHTML.prototype.draw = function() {
      var self = this;
      var div = this.div;
  
      //Create div if there's none
      if (!div) {
  
          div = this.div = document.createElement('div');
          div.className = 'custom-html';
  
          var panes = this.getPanes();
          panes.overlayImage.appendChild(div);
      }
  
      //Location on map - not relevant for this question
      var point = this.getProjection().fromLatLngToDivPixel(this.latlng);
      if (point) {
          div.style.left = (point.x - 20) + 'px';
          div.style.top = (point.y - 64) + 'px';
      }
  };
  
  //Create new objects
  var data = /*parsed JSON*/;
  var count = data.lenght;
  var myMap = /*Google Map object - not relevant for this question*/;
  
  for(i=0; i&lt;count; i++) {
      new CustomHTML(data[i].latlng, data[i].foo, myMap);
  }
  </code></pre>
  
  <p><strong>Somewhere else in the code:</strong></p>
  
  <pre><code>//Clicking element that was made above
  jQuery('body').on('click', '.custom-html', function(event) {
  
        //I need to access customHTML.foo for example, how?
        //PS! I need to access it from outside, I cannot 
        //attach this click event in prototype.draw
  }
  </code></pre>