Skip to content

Instantly share code, notes, and snippets.

@zenideas
Created May 27, 2013 11:45
Show Gist options
  • Save zenideas/5656634 to your computer and use it in GitHub Desktop.
Save zenideas/5656634 to your computer and use it in GitHub Desktop.
<div class="tour" data-daily-price="357">
<h2>Paris, France Tour</h2>
<p>$<span id="total">0</span> for <span id="nights-count">2</span> Nights</p>
<p>
<label for="nights">Number of Nights</label>
</p>
<p>
<input id="nights" value="7" type="number">
</p>
</div>
$(document).ready(function() {
$("#nights").on("keyup", function() {
var nights = $(this).val();
var daily_price = $(this).closest('.tour').data('daily-price');
var total = daily_price * nights;
$("#nights-count").text(nights);
$("#total").text(total);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment