The following code doesn’t seem to work. How would I change it in order to make the div change the position from top?
div { width:220px; height:170px; margin: 10px 50px 10px 10px;
background:yellow; border:2px groove; float:right; }
#alt { width:20px; height:170px; margin: 10px 50px 10px 10px;
background:blue; border:2px groove; float:right; }
#altLevel { width:10px; height:20px;
background:red; border:2px groove; }
$('div').mouseclick(function() {
$( '#altLevel').css( 'top', '+=10' );
});
You have to add
position:absoluteorposition:fixedto the styles for#altLevelbefore you can alter its position. In addition, give it a default position oftop:0or whatever you like:Once you do that, your JavaScript should work with a small modification:
http://jsfiddle.net/mblase75/mGAKe/