peter
peter

Reputation: 169

trigger function on page load, javascript

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';
}

Upvotes: 0

Views: 90

Answers (1)

Manish Shukla
Manish Shukla

Reputation: 1365

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

Upvotes: 1

Related Questions