JQuery using object literal can't using $(this) always undefine on onclick
<p>my problem after write as object literal as Jquery guide i can't using $(this) to access self on onlick="". please help correct my mistake.</p>

<p>my html</p>

<pre><code>&lt;a 
 data-id="&lt;?=$product_id?&gt;" 
 class="compare product-&lt;?=$product_id?&gt;" 
 onclick="(function(){compareInit.comGet();})()"
&gt;&lt;/a&gt;
</code></pre>

<p>my js </p>

<pre><code>   var compareInit = {

     /*  Store Item Compare  */
      comGet: function() {

          var e = $(this);
          var item_id = e.data('id');
          var item_image = e.find(".compare-hidden-image").val();
          var item_name = e.find(".compare-hidden-name").val();
          var count_item = $(".compare-item").length;
          var item_dialog = $(".compare-tray-dialog");
          var compare_button = $(".compare-tray-item");
          item_dialog.show();

          if (count_item &gt; 1) {
          } else {
            $(".product-"+ item_id).css("color", "red").attr('onclick','');
          }
          if (count_item === 0) {
            compare_button.removeClass('activate').addClass('deactivate');
          } else {
            compare_button.removeClass('deactivate').addClass('activate');
          }
          $('.compare-remove').on("click", function() {
            var rem_id = $(this).data('id');
            $("." + rem_id).remove();
            $(".product-" + rem_id).css("color", "#fff").attr('onclick','(function(){compareInit.comGet();})()');
            compare_button.removeClass('activate').addClass('deactivate');
          });
      }
    };
</code></pre>

<p>Thank in advance.</p>