Trying to understand how the this keyword works. For example on this code, this is refering to "button" right? (or to the action of clicking the button). Thank you
$(document).ready(function(){
$("button").on("click", function(){
var discount = $(this).closest(".tour").data("discount");
var message = $("<span>Call 1-555-jquery-air for a $discount discount.</span>");
$(this).closest(".tour").append(message);
$(this).remove();
});
});
HTML here:
<div id="tours">
<h1>Guided Tours</h1>
<ul>
<li class="usa tour" data-discount="299">
<h2>New York, New York</h2>
<span class="details">$1,899 for 7 nights</span>
<button class="book">Book Now</button>
</li>
<li class="europe tour" data-discount="176">
<h2>Paris, France</h2>
<span class="details">$2,299 for 7 nights</span>
<button class="book">Book Now</button>
</li>
<li class="asia tour" data-discount="349">
<h2>Tokyo, Japan</h2>
<span class="details">$3,799 for 7 nights</span>
<button class="book">Book Now</button>
</li>
</ul>
</div>