title: onclick event inside bootstrap popover
body: <p>When <strong>inbox</strong> button is clicked it runs <strong>inbox_open()</strong> function
  and in inbox header 3 buttons appear but onclick event listener is missing.
  Check code after <code>// inbox.open</code> comment, critical lines: <code>b.onclick = function() { console.log("button was clicked"); }</code> and<code>inbox.setAttribute("title", poH.innerHTML);</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>// inbox
  var inbox = document.getElementById("inbox");
  var inbox_news = document.getElementById("inbox_news");
  
  var poH = document.createElement("span");
  var poC = document.createElement("span");
  
  var new_from_to = [0, 2, 3];
  var number_of_news = [2, 1, 2];
  var news_price_data = [10, 20, 30, 40, 50];
  
  // inbox.open
  function inbox_open() {
    for (var i = 0; i &lt; number_of_news.length; i++) {
      var b = document.createElement("button");
      b.innerHTML = (i + 1);
      b.className = "poH";
      b.onclick = function() {
        console.log("button clicked");
      }
      poH.appendChild(b);
    }
    inbox.setAttribute("title", poH.innerHTML);
  }
  
  // inbox.addEventListener
  inbox.onclick = inbox_open();
  
  // aloud BS 4 popover to run
  $(document).ready(function() {
    $('[data-toggle="popover"]').popover();
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"&gt;
  
  &lt;!-- HTML --&gt;
  &lt;button id="inbox" class="btn btn-primary btn-sm" style="float: right; margin: 30px 30px 0 0;" data-toggle="popover" data-placement="left" data-html="true" title="" data-content=""&gt;inbox &lt;span id="inbox_news"&gt;&lt;/span&gt;&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>