title: HTML elements created by the content script are not accessible by the content script
body: <p>Within content script I use on.Message.addListener to add images with a class name to the currently active web page.</p>
  
  <p>chrome.extension.onMessage.addListener(function (message, sender, sendResponse) {</p>
  
  <pre><code>// Selecting HTML tags
  var divs = document.getElementsByTagName("div");
  
  // Creating a full URL to use icon1
  var imageUrl = chrome.extension.getURL("icons/icon1.png");
  
  // Function to create an image
  function PlaceImage(source_x, source_y, imageUrl) {
  
      var newImage = document.createElement("img");
  
      newImage.src = imageUrl;
  
      newImage.style.position = "absolute";
      newImage.style.left = source_x + 'px';
      newImage.style.top = source_y + 'px';
  
      // Assigning a class name
      newImage.className = "label-key";
  
      // Add an element to the HTML document
      document.body.appendChild(newImage);
  
  }
  
  // Divs
  for(var j=0; j&lt;divs.length; j++) {
  
      // Get the position of an element with getBoundingClientRect
      var position = divs[j].getBoundingClientRect();
      var x = position.left;
      var y = position.top;
      y -=32;
  
      // Create comment image
      PlaceImage(x, y, imageUrl);
  }
  </code></pre>
  
  <p>});</p>
  
  <p>Later I try to write to console by clicking on one of just created images by:</p>
  
  <pre><code>$(".label-key").click(function () {
      console.log("hello");
  });
  </code></pre>
  
  <p>There is no reaction of the browser.</p>
  
  <p>I tried to write to console by accessing some class element with a different name, which was part of the original web page(received from the server). It worked fine.</p>
  
  <p>More over I created another element within content script, but this time outside of onMessage.AddListener:</p>
  
  <pre><code>var newDiv = document.createElement("div");
  document.body.appendChild(newDiv);
  newDiv.style.width = "100px";
  newDiv.style.height = "100px";
  newDiv.style.backgroundColor = "red";
  newDiv.className = "label-key";
  </code></pre>
  
  <p>It also worked fine. jQuery was able to access this element.</p>
  
  <p>Therefore, I think there is something wrong with html elements created by the onMessage.addListener part of content script.</p>
  
  <p>For additional reference: when I right-click on the newly created element "Inspect element" - I can see that the element is part of the html document. However, if I click "View page source" the element is not there.</p>