Home >Web Front-end >JS Tutorial >Detailed explanation of javaScript page automatic loading event_javascript skills

Detailed explanation of javaScript page automatic loading event_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:00:511213browse
Method 1:
Copy code The code is as follows:

Window.onload =function(){
Var name=document.getElementById(“name”).val();//Load HTML and load all external reference files (images, css styles, js, etc.)
}

Method 2: Need to introduce Jquery .js file
Copy code The code is as follows:

$(document).ready(function(){
                                                                                                                                                                                                                               alert("JQuery's first introductory case");//Load HTML, no need to wait, immediately Loading
});

Method 3: (Equivalent to method 2)
Copy code The code is as follows:

jQuery(function (){
                                                                                                                                         ")
alert($("input[name='message']").attr("value"));
});

Method 4: (Same as above)
Copy code The code is as follows:

$(function ( ){
alert("Execute 1 when JQuery page is automatically loaded....");
});

Method 5-1: window.onload event Loading (Load multiple functions at the same time when the page loads...)
Copy code The code is as follows:







Method 5-2: Loading of window.onload event (multiple functions are loaded at the same time when the page is loaded...)
Copy code The code is as follows:





<script><br> function1(){<br> }<br> function2(){<br> }<br> function3(){<br> }<br> window.onload=function() {<br> function1();<br> function2();<br> function3();<br> }<br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn