I want to use the below code to add an onClick
event to a button.
document.getElementById("first").addEventListener("click", changeHeight);
function changeHeight() {
var panelH = document.getElementById('second');
if (panelH.style.height == '')
panelH.style.height = '160px';
else
panelH.style.height = '';
}
but just works when is wrapped inside this:
window.onload = function() {
}
What should I change in other to use that code without using window.onload
event?