css - jQuery does not add values, but lines them -
this maybe silly question, lost!
so, trying change div height jquery adding values, not adding up, lining. maybe of have had same problem?
my code:
jquery( document ).ready(myfunction); $(window).resize(myfunction); function myfunction() { var divh = $('.container').css("height"); divh = divh .replace(/px/g, ""); var innerh = divh + 130; $('.divright').css("width", innerh); }
for example, .container height 100px, output should 230px (100+130), instead shows 100130
do guys have idea why???
thank in advance!
the issue because concatenating string values, instead of adding integers. need convert height()
value int can achieve using parseint()
:
$(document).ready(myfunction); $(window).resize(myfunction); function myfunction() { var divh = parseint($('.container').css("height"), 10); var innerh = divh + 130; $('.divright').css("width", innerh); }
Comments
Post a Comment