Reputation: 25
sorry for the complex expression of my question.
I would set the height of the div #space, taking the height of another div that's have a class .ls-wp-fullwidth-container.
I try this:
$(document).ready(function() {
var altezza = document.getElementById(".ls-wp-fullwidth-container").clientHeight;
$("#space").height(altezza);
});
// for the window resize
$(window).resize(function() {
var altezza = $(".ls-wp-fullwidth-container").height();
$("#space").height(altezza);
});
How can I do?
Thanks for the help.
Upvotes: 0
Views: 80
Reputation: 6349
You should get the div through class selector by $(.className)
but you used document.getElementById(".ls-wp....")
which is wrong
Updated
should be
var altezza = $(".ls-wp-fullwidth-container").height();
Or
var altezza = $(".ls-wp-fullwidth-container")[0].clientHeight;
instead of
document.getElementById(".ls-wp-fullwidth-container").clientHeight;
When you use the class
selector to fetch the data it returns array of matched elements. And when you use id
it returns matched element only.
Upvotes: 1
Reputation:
Here's a fiddle: http://jsfiddle.net/HzQhL/
$("#space").height($(".ls-wp-fullwidth-container").height());
Upvotes: 1
Reputation: 389
see this
var height = $(".ls-wp-fullwidth-container").css("height");
$("#space").css("height", height);
Upvotes: 0