title: How to pass parameters to a javascript function on onclick?
body: <p>I have a script where i want to call another function on onclick by passing parameters.I want to call remove_product function .How can i achieve this?</p>
  
  <pre><code>function load_cart(){
  $('.mini-cart-products').html('');
  var url = $('.ajax-url').attr('href');
  var t   = 0;
  // console.log(url);
  $.ajax({
      url     : url,
      dataType:'json',
      success:function(result){
  
          if(result.length &gt; 0)
          {
              var image       = $('.mini-cart-image a img');
              var prod_name   = $('.mini-cart-name a');
              var attribute   = $('.mini-cart-attributes');
              var pricing     = $('.mini-cart-pricing');
  
              $.each(result, function(key, val){
  
                  var remove_url = val.remove;
                  var barcode = val.barcode;
                  var cart_id = val.cart_id;
                  console.log("remove_url :"+remove_url+" barcode : "+barcode+" cart_id : "+cart_id);
                  var productDiv  = $( "&lt;div class='mini-cart-product clearfix'&gt;&lt;/div&gt;" );                                             
                  var nameDiv     = '&lt;div class="mini-cart-name font"&gt;&lt;a href="'+val.link+'"&gt;'+val.name+'&lt;/a&gt;&lt;/div&gt;';
                  var attributes  = $( "&lt;div class='mini-cart-attributes'&gt;&lt;/div&gt;" );
                  var colorAttr   = '&lt;div class="attribute"&gt;&lt;span class="label"&gt;Colour: &lt;/span&gt;&lt;span class="value"&gt;'+val.color+'&lt;/span&gt;&lt;/div&gt;';
                  var sizeAttr    = '&lt;div class="attribute"&gt;&lt;span class="label"&gt;Size&amp;nbsp&amp;nbsp&amp;nbsp: &lt;/span&gt;&lt;span class="value"&gt;'+val.size+'&lt;/span&gt;&lt;/div&gt;';
                  var remove  = '&lt;div class="mini-cart-remove"&gt;&lt;a onclick="remove_product(remove_url,barcode,cart_id)"&gt;Remove&lt;/a&gt;&lt;/div&gt;';
  </code></pre>