Skip to content

Instantly share code, notes, and snippets.

@nastysloper
Created June 9, 2013 21:31
Show Gist options
  • Save nastysloper/5745319 to your computer and use it in GitHub Desktop.
Save nastysloper/5745319 to your computer and use it in GitHub Desktop.
http://jsfiddle.net/nastysloper/jGq7E/ Calculates price for package deal.
$(document).ready(function() {
$("#nights").on("keyup", function() {
$("#nights-count").text($(this).val());
var nights = +$(this).val();
var dailyPrice = +$(this).closest('.tour').data('daily-price');
$('#total').text(nights * dailyPrice);
$('#nights-count').text($(this).val());
});
});
<div class="tour" data-daily-price="357">
<h2>Paris, France Tour</h2>
<p>$<span id="total">2,499</span> for <span id="nights-count">7</span> Nights</p>
<p>
<label for="nights">Number of Nights</label>
</p>
<p>
<input type="number" id="nights" value="7">
</p>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment