Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active January 30, 2018 11:02
Show Gist options
  • Select an option

  • Save desinas/6c3649cf73bbaf3d9ec7a5c4f9ca945f to your computer and use it in GitHub Desktop.

Select an option

Save desinas/6c3649cf73bbaf3d9ec7a5c4f9ca945f to your computer and use it in GitHub Desktop.
try jQuery by Code school / Listening to DOM events / expanding on on()
//chapt4.8 Mouseover I, 4.9 Mouseover II, 4.10 Mouseleave, 4.11 Named Functions
$(document).ready(function() {
$('#tour').on('click', 'button', function() {
$('.photos').slideToggle();
});
function showPhotos() {
$(this).find('span').slideToggle();
}
$('.photos').on('mouseenter', 'li', showPhotos);
$('.photos').on('mouseleave', 'li', showPhotos);
});
<div id="tour">
<h2>Paris, France Tour</h2>
<p>$2,499 for 7 Nights</p>
<button>See photos from our last tour</button>
<ul class="photos">
<li>
<img src="/assets/photos/paris1.jpg">
<span>Arc de Triomphe</span>
</li>
<li>
<img src="/assets/photos/paris2.jpg">
<span>The Eiffel Tower</span>
</li>
<li>
<img src="/assets/photos/paris3.jpg">
<span>Notre Dame de Paris</span>
</li>
</ul>
</div>
@desinas
Copy link
Copy Markdown
Author

desinas commented Jan 30, 2018

screen shot 2018-01-30 at 12 56 26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment