For the code structure here
var mydo=sessionStorage.getItem("action");
function to_delete(){
var _table=document.getElementById("showTable");
//omit
}
window.onload=function(){
to_delete();
}
I get desired result. Now rewrite the code structure as below:
var mydo=sessionStorage.getItem("action");
var _table=document.getElementById("showTable");
function to_delete(){
//omit
}
window.onload=function(){
to_delete();
}
An error occur, TypeError: _table is null
.
Why can't set document.getElementById
to be global variable?