Add in integer to returned value with jQuery

Posted by danferth on Stack Overflow See other posts from Stack Overflow or by danferth
Published on 2011-11-17T01:36:39Z Indexed on 2011/11/17 1:50 UTC
Read the original article Hit count: 154

Filed under:

I have a page with a div id="videoFrame" that holds the video tag. The videos have variable heights so I have a function to grab the height value and plug it into the css of the div id="videoFrame like so:

var videoHeight = $('video').attr('height');
$('#videoFrame').css('height',videoHeight+'px');

This works great. But here's the part driving me crazy. I have a p tag with disclaimers at the bottom of the div id="videoFrame". So I would like to add an additional 26px to the returned height. I tried:

var videoHeight = $('video').attr('height');
var frameHeight = videoHeight + 26;
$('#videoFrame').css('height',frameHeight+'px');

But as you would expect it is adding 26 to the end of the returned value. i.e. if returned value is 337 output for var frameHeight is 33726.

I can not for the life of me figure out how to do this.

Thanks in advance for any help

© Stack Overflow or respective owner

Related posts about jQuery