Reputation: 322
I don't know why it can't find the height. Any help would be appreciated.
var h = document.getElementById('big_button').clientHeight,
center = -h / 2;
window.onload = function () {
document.getElementById('big_button_container2').style.marginTop = 'center';
};
Upvotes: 2
Views: 30964
Reputation: 356
You can use document.getElementsByClass instead as you have only elements with class names not IDs.
i.e.
var h = document.getElementsByClassName('big_button')[0].clientHeight,
center = -h / 2;
window.onload = function () {
document.getElementsByClassName('big_button_container2')[0].style.marginTop = 'center';
};
Upvotes: 2