When the page opens, we need to perform some operations. At this time, if we choose to use jquery, we need to rewrite its 3 methods
No, it’s up to you. The second feeling is simple:
The first:
<script type="text/javascript" src="./js/jquery-1.7.min.js"></script>
<script type="text/javascript">
//init method one
$(document).ready(function(){
trace(" The initialization method enters ");
});
function trace(obj){
console.log(obj);
}
</script>
Firefox press f12 to debug why use console.log instead of alert! This everybody should be clearer! The second:
<script type="text/javascript">
//init method one
$(function(){
trace(" The initialization method enters two ");
});
function trace(obj){
console.log(obj);
}
</script>
The third:
<script type="text/javascript" src="./js/jquery-1.7.min.js"></script>
<script type="text/javascript">
//init method one
jQuery(function($){
trace(" The initialization method enters three ");
});
function trace(obj){
console.log(obj);
}
</script>
Ps. Instead of using jquery to initialize a page,
1. Inside the body, “onload”
2. Write it in a script
window.onload=function(){
//Something to initialize
}