title: jQuery button click attr('src') returns 'Cannot read property 'on' of null'
body: <p>I'm trying to click on the image and capture the url:</p>
  
  <pre><code>  $(".imageitemaddt").on("click", function() {
           imgitem = $(this).attr('src');
           alert(imgitem);
    }); 
  
    fabric.Object.prototype.transparentCorners = false;
    var $ = function(id){return document.getElementById(id)};
  
    fabric.Image.fromURL(imgitem, function(img) {
      var oImg = img.set({ left: 50, top: 100, angle: -15 }).scale(0.9);
      canvas.add(oImg).renderAll();
      canvas.setActiveObject(oImg);
  
       img.animate('left', 200, {
          onChange: canvas.renderAll.bind(canvas)
      });
  
    });
  
    $('grayscale').onclick = function() {
      applyFilter(0, this.checked &amp;&amp; new f.Grayscale());
    };
    $('invert').onclick = function() {
      applyFilter(1, this.checked &amp;&amp; new f.Invert());
    };
    $('remove-white').onclick = function () {
      applyFilter(2, this.checked &amp;&amp; new f.RemoveWhite({
        threshold: $('remove-white-threshold').value,
        distance: $('remove-white-distance').value
      }));
    };
  </code></pre>
  
  <p>Returns:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'on' of null</p>
  </blockquote>
  
  <hr>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>add code:</p>
  
  <pre><code>    function addtoo(img)
      {
      var nameim = img.src;
  
  }
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>function addtoo(img)
  {
  var nameim = img.src;
  
    fabric.Image.fromURL(nameim, function(img) {
      var oImg = img.set({ left: 50, top: 100, angle: -15 }).scale(0.9);
      canvas.add(oImg).renderAll();
      canvas.setActiveObject(oImg);
  
       img.animate('left', 200, {
          onChange: canvas.renderAll.bind(canvas)
      });
  
    });
  
    }
  </code></pre>
  
  <p>in the button:</p>
  
  <pre><code>&lt;img onclick="addtoo(this)" src="http://lorempixel.com/200/200"/&gt;
  </code></pre>
  
  <p><a href="https://jsfiddle.net/wvcsu6ho/6/" rel="nofollow">https://jsfiddle.net/wvcsu6ho/6/</a></p>
  
  <p>Thanks for any help</p>