The goal is simple. When hover over mydiv (gray) the child div of inner should appear. I'm trying to write code for that but the best I can come up with is showing all inner divs. Only the child inner div should appear. Please help me with the code for this, I will appreciate it, thank you :)
https://jsfiddle.net/wyeqgfjz/#&togetherjs=6wNtokkegm
HTML:
<div class="mydiv">
<div class="inner"></div>
</div>
<div class="mydiv">
<div class="inner"></div>
</div>
CSS:
.mydiv {
background: #ccc;
padding: 40px;
margin-bottom: 40px;
}
.inner {
background: red;
padding: 40px;
}
jQuery:
var inner = $('.mydiv .inner'),
mydiv = $('.mydiv');
inner.hide();
mydiv.each(function() {
$(this).on('hover', function() {
$(this).find(inner).toggle();
});
});