title: How to resolve Uncaught TypeError: Cannot set property 'outerHTML' of null?
body: <p>The error is not disabling the page from rendering correct results; however, it is quite annoying! I am showing the HTML and JavaScript portion of the code where the error is originating from. Please assist me with this as I have been attempting to resolve the issue for hours now without any effect! </p>
  
  <p>Code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>google.charts.load("current", {packages:['corechart']});
  google.charts.setOnLoadCallback(drawChart);
  
  function drawChart() {
  
   var data = google.visualization.arrayToDataTable([
    ['Element', 'Density', { role: 'style' }],
    ['Copper', 8.94, '#b87333', ],
    ['Silver', 10.49, 'silver'],
    ['Gold', 19.30, 'gold'],
    ['Platinum', 21.45, 'color: #e5e4e2' ]
   ]);
  
   var options = {
    title: "Density of Precious Metals, in g/cm^3",
    bar: {groupWidth: '95%'},
    legend: 'none',
   };
  
   var chart_div = document.getElementById('chart_div');
   var chart = new google.visualization.ColumnChart(chart_div);
  
   google.visualization.events.addListener(chart, 'ready', function () {
    chart_div.innerHTML = '&lt;img src="' + chart.getImageURI() + '"&gt;';
    console.log(chart_div.innerHTML);
   });
  
   chart.draw(data, options);
   document.getElementById('png').outerHTML = '&lt;a href="' + chart.getImageURI() + '" target="_blank"&gt;&lt;span class="glyphicon glyphicon-print"&gt;&lt;/span&gt;&lt;/a&gt;';
  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"&gt;
  &lt;script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;!-- Chart 1 --&gt;
  &lt;button class="btn btn-primary" onclick="drawChart()" data-toggle="modal" data-target="#myModal"&gt;Chart&lt;/button&gt;
  
  &lt;!-- Modal 1 --&gt;
  &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
   &lt;div class="modal-dialog"&gt;
    &lt;div class="modal-content"&gt;
     &lt;div class="modal-header"&gt;
      &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
     &lt;/div&gt;
     &lt;div class="modal-body"&gt;
      &lt;div id="chart_div"&gt;&lt;/div&gt;
     &lt;/div&gt;
     &lt;div class="modal-footer" style="text-align: center;"&gt;
      &lt;div id='png'&gt;&lt;/div&gt;
     &lt;/div&gt;
    &lt;/div&gt;
   &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>