I'm confident that this code should be functioning properly, but for some reason it's not. I feel like there must be a small detail that I'm overlooking:
Markup:
<section id="content"></section>
Styling:
#content {
position: relative;
background: green;
width: 300px;
height: 150px;
margin-top: 20px;
}
JavaScript:
$('#content').click(function(e) {
if (e.ctrlKey)
$(this).css('top', '50px');
else
$(this).css('top', '+=25');
});
If you ctrl+click, the content section moves correctly. However, clicking without holding ctrl does not increase the top position of the section by 25px. What could be causing this unexpected behavior?