I have managed to stick together the following code from various sources, but now I'm completely stuck!
$(document).ready(function(){var return_height = $("#columns").outerHeight();
var a = document.getElementsByTagName('p');
a[0].innerHTML += return_height;
});
The current code will return the value within the first 'p' tag. I need the value to be returned on a specific div like this;
<div id="column-container" style="height: return_height ">
How would I achieve this?
Try this:
var return_height = $("#columns").outerHeight();
$('#column-container').height(return_height);
Using JavaScript
document.getElementById("column-container").style.height = return_height + "px";
Using jQuery
$("#column-container").height(return_height);
You can use jQuery's .css()
method to set the height of your div:
$(document).ready(function(){
$('#column-container').css('height', $("#columns").outerHeight());
});
.height()
works, too:
$(document).ready(function(){
$('#column-container').height($("#columns").outerHeight());
});