0

I have a page and I want to run a function called "toggle_visibility" on page load. This is what I have so far and it's not quite doing the job, how can I improve this? No jQuery, please. This is the on load trigger:

function toggletrigger() {
    toggle_visibility;
}

window.onload = toggletrigger;

and this is the function that I want to run on page load:

function toggle_visibility(id) {
    var e = document.getElementById(id);

    if(e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
}
2

1 Answer 1

1

toggle_visibility function need a parameter but you are not passing parameter while calling this function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.