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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -