I'm trying to add two variables together (two different heights) but for some odd reason even though they are both numbers, it is not adding them together and just refusing to do anything. How do I add two variables together?
HTML
<div id="imageSlider">
<div id="imagesContainer">
<div class="left" id="selectedImage">
<div class="sliderImageAlign">
</div>
</div>
</div>
<div id="imagesUp">
<div id="imagesArrowUp"></div>
</div>
<div id="imagesDown">
<div id="imagesArrowDown"></div>
</div>
</div>
jQuery
$(document).ready(function(){
var imageHeight = $("#selectedImage").height(),
containerHeight = $("#imagesContainer").height(),
containerPos = $("#imagesContainer").position();
$("#tellMeHeight").text(containerHeight / imageHeight);
$("#imagesDown").click(function(){
var containerNewPos = parseInt(containerPos + imageHeight);
$("#imagesContainer").css({
top: containerNewPos + 'px'
});
});
});
.position()returns an object: api.jquery.com/position . So you can't exactly add something to it...containerPoscontains the result of callingposition(), so it is storing an object. If you want to do a calculation with it, usecontainerPos.leftorcontainerPos.topto get the specific property