Reputation: 211
Hi I want to know how I can duplicate the following behaviour using jQuery's shortcut method of mouseenter apposed to using mouseenter via the on() jQuery method.
basic code below: html
<dl>
<dt>tab 1</dt>
<dd>info.</dd>
<dt>tab 2</dt>
<dd>info.</dd>
<dt>tab 3</dt>
<dd>info.</dd>
</dl>
jQuery -
$('dl').on('mouseenter', 'dt', function() {
$(this)
.next()
.slideDown(200)
});
so the above behaviour where only the 'dt' elements are in the jQuery collection using the below shortcut.
$('dl').mouseenter(function() {
$(this)
.next()
.slideDown(200)
});
jsfiddle:
thanks
Upvotes: 0
Views: 93
Reputation: 2529
You can use this too
$('dl').find('dt').mouseenter(function () {
$(this).next().slideDown(200)
});
Upvotes: 0
Reputation: 388316
Since you are targeting dt
elements under dl
element, you need to use the descendant selector
$('dl dt').mouseenter(function () {
$(this).next().slideDown(200)
});
Demo: Fiddle
Upvotes: 1