I am facing an issue where each blue div (
<div id="rectangle"></div>
) is not firing independently when hovered or clicked.
Currently, when I hover/click over the first one, both fire simultaneously. However, if I hover/click over the second one, neither fires.
I have tried various solutions from other sources but none seem to work with this specific code. I was hoping someone could provide me with a detailed explanation so I can learn and compare it to the methods I have already attempted.
$('.rectangle1').hide();
$('#rectangle').on('click', function() {
clicked = !clicked;
});
$('#rectangle').hover(function() {
$('.rectangle1').slideDown()
},function() {
if (!clicked) {
$('.rectangle1').slideUp()
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="rectangle"></div>
<div class="rectangle1"></div>
<div id="rectangle"></div>
<div class="rectangle1"></div>