1. 程式人生 > >jquery頁面載入就執行

jquery頁面載入就執行

window.onload = function() { 
$(".active").removeClass("active");
$("#about").addClass("active");
}; 


$(document).ready(function(){ 
$(".active").removeClass("active");
$("#about").addClass("active");
});

$(function(){ 
$(".active").removeClass("active");
$("#about").addClass("active");

});

也可以在上面增加 方法體內增加,方法通過事件觸發

 $(function(){ 

 function xxx(){

                    alert("hello world!");

                };

 });