2013年9月15日星期日

js understanding questions ?

Specific issues : document.getElementById can not function in use it ?
js following judgments rs is null , it is, hidden tab1 , tab2 show , not vice versa
if (<% = rs.size () == 0? false: true%>) {
document.getElementById ("tab2"). style.display = "none";
document.getElementById ("tab1"). style.display = "block";
}
else {
document.getElementById ("tab2"). style.display = "block";
document.getElementById ("tab1"). style.display = "none";
}}

pieces written directly in js is not executed , have set into window.onload = new funtion () {}
I ask why ? document.getElementById there any usage restrictions it ? Ask
------ Solution --------------------------------------- -----
can also be used outside the function .

directly on the script tag is useless, possible causes are: not really a page has finished loading , on the window.onload function can ensure that the page has finished loading , the script was executed.

window.onload may not be placed in the end of the script on the page is also OK .
------ Solution ---------------------------------------- ----
page loads too slowly, yet implementation of this statement
------ Solution ---------------------- ----------------------
document.getElementById ("tab2")
document.getElementById ("tab1")
page load tab1 and tab2 have finished the above two objects , you do not want to put you into the js window.onload inside html code into the bottom .
------ For reference only -------------------------------------- -
upstairs very strong.
------ For reference only -------------------------------------- -
js no effect because your table has not been created , this does not exist in the dom node , document.getElementById ("tab2")
, if you alert the next time you will find that undefined, you can put this js on these two table behind the use of , or only onload method uses
------ For reference only - -------------------------------------
jsp recorded in the order of static html, js, document.getElementById what time can be used, but here it is not running , you can write a few alert statements for debugging ! I hope to help you
------ For reference only --------------------------------- ------
god, upstairs are the master, thanks

没有评论:

发表评论