I had assumed this would be a simple issue, but after searching through the forum, I couldn't find a solution.
From the title, you can tell what's wrong. My code is mistakenly hiding the #player-one-turn
element within the parent element #fourth-step
(although every element belongs to the body
element). I'm hesitant to modify the DOM structure. Could it be necessary? I'm not sure.
$("#fourth-step").not($('#player-one-turn')).animate({
opacity: 0
});
// SAME AS ABOVE - DOESN'T WORK
//$("#fourth-step:not('#player-one-turn')").animate({ opacity: 0 });
//$("#fourth-step:not('#player-one-turn')").animate({ opacity: 0 });
//$("#fourth-step:not(#player-one-turn)").animate({ opacity: 0 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fourth-step">
<div id="player-one-turn">
DONT HIDE ME PLS
</div>
asd asd as das das das d asd as
</div>
For better editing, here is the JsFiddle link: https://jsfiddle.net/ax07dnrf/1/.
Multiple attempts were made with no success:
$("#fourth-step").not($('#player-one-turn')).animate({ opacity: 0 });
$("#fourth-step:not('#player-one-turn')").animate({ opacity: 0 });
$("#fourth-step:not('#player-one-turn')").animate({ opacity: 0 });
$("#fourth-step:not(#player-one-turn)").animate({ opacity: 0 });
Could there be a syntax error? Unlikely :D
Similar threads didn't provide a working solution for my problem, despite trying both :not()
and .not()
:
- Select all body except one element
- jquery - run function on each element except the one that was clicked