In the following code, after the jQuery runs, I expected only 2 to be seen with background red.
However, after jQuery runs, I can see 1, 2 and 3 with their backgrounds red.
Where is the glitch?
HTML
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('div').css('display','block').css('background','red');
});
</script>
</head>
<body>
<div style="display:none">1</div>
<div style="display:block">2</div>
<div style="display:none">3</div>
</body>
</html>
Output
