Skip to content

Instantly share code, notes, and snippets.

@emaildano
Last active September 6, 2017 04:59
Show Gist options
  • Save emaildano/c2f9a5c1e838ae2ce2f0c9f6ecd17fde to your computer and use it in GitHub Desktop.
Save emaildano/c2f9a5c1e838ae2ce2f0c9f6ecd17fde to your computer and use it in GitHub Desktop.
Percentage off Month Plans
<div class="personal">
  <div class="amimoto-pricing-data" data-monthly="30">$<span class="price">30</span></div>
  <div class="amimoto-pricing-data" data-monthly="60">$<span class="price">60</span></div>
</div>

<div class="business">
  <div class="amimoto-pricing-data" data-monthly="600">$<span class="price">600</span></div>
  <div class="amimoto-pricing-data" data-monthly="900">$<span class="price">900</span></div>
</div>
      function percentage(num, per) {
        return (num/100)*per;
      }

      $('.personal .amimoto-pricing-data').each( function() {
        var discount = 10;
        var annual_full = $(this).data('monthly') * 12;
        var annual_off = annual_full - percentage(annual_full, discount);
        $(this).attr('data-annual', annual_off);
        console.log(annual_off);
      });

      $('.business .amimoto-pricing-data').each( function() {
        var discount = 15;
        var annual_full = $(this).data('monthly') * 12;
        var annual_off = annual_full - percentage(annual_full, discount);
        $(this).attr('data-annual', annual_off);
        console.log(annual_off);
      });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment