Categories: jQuery

페이지 로드 완료되었을때 실행

페이지가 로드 완료 되었을때 스크립트 실행하는방법입니다.
<body onload=’script’>처럼 사용하는 방법도 있겠지만..
jquery를 이용하여 로드 완료 되었을 때 처리하는 방법을 설명하겠습니다.
learn.jquery.com/using-jquery-core/document-ready

<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>

<script>
//첫번째 방법
$(document).ready(function(){ 
    alert(1); 
});

//두번째 방법
$(function(){
    alert(1);
});
</script>
Related Post