DOM構築後に実行 jQueryの場合 $(document).ready(function(){ // Document is ready }); もしくは $(function(){ // Document is ready }); 最近のJavaScriptの場合 document.addEventListener('DOMContentLoaded', function(){ // Document is ready }, false); CSSセレクタによる要素選択 jQueryの場合 $('#myid'); 最近のJavaScriptの場合 単数選択 document.querySelector('#myid'); 複数選択 document.querySelectorAll('.ourid'); Foreach文 jQueryの場合 $.each(['a', 'b', 'c'