掌田津耶乃(7歳)から学ぶJS DOM その1 djakarta-tra.. Follow 2010-06-25 19:39:07 License: MIT License Fork2 Fav0 View739 Play Stop Reload Fullscreen Smart Phone Fork tree Readme JavaScript 21 lines HTML 7 lines CSS 1 lines 掌田津耶乃(7歳)から学ぶJS DOM その1 document.getElementById("content").innerHTML = "ノッチです"; //<html>...</html>がはいった、Documentクラスのインスタンス(オブジェクト) console.log(document); //<body>...</body>そのものが返ってきてる。 //だから、document.body.p とか、APIをたどっていくような処理はできない。 //getElementById してやる必要がある。 console.log(document.body); // だから、undefinedが返る。 console.log(document.body.p); //objectと返る。なんのだろ・・・。String? console.log(typeof(document.getElementById("content")) ); function doAction(){ document.getElementById("content").innerHTML = "クリックしたな"; } <h1 id="title">yes we can</h1> <p id="content">obama</p> <!-- void(0)は、空撃ち関数。 onClick参照は、クリックされた時のハンドラ的な。 --> <a href="javascript:void(0)" onClick="doAction();">click me !</a> 掌田津耶乃(7歳)から学ぶJS DOM その1 body { background-color: #DDDDDD; } document.getElementById("content").innerHTML = "ノッチです"; //<html>...</html>がはいった、Documentクラスのインスタンス(オブジェクト) console.log(document); //<body>...</body>そのものが返ってきてる。 //だから、document.body.p とか、APIをたどっていくような処理はできない。 //getElementById してやる必要がある。 console.log(document.body); // だから、undefinedが返る。 console.log(document.body.p); //objectと返る。なんのだろ・・・。String? console.log(typeof(document.getElementById("content")) ); function doAction(){ document.getElementById("content").innerHTML = "クリックしたな"; } <h1 id="title">yes we can</h1> <p id="content">obama</p> <!-- void(0)は、空撃ち関数。 onClick参照は、クリックされた時のハンドラ的な。 --> <a href="javascript:void(0)" onClick="doAction();">click me !</a> body { background-color: #DDDDDD; } use an iframe compat browser, deer Play on jsdo.it games Share Embed QR Tag Download Complete! Description どんなゲームですか? Control Device スマートフォンコントローラー jsdo.it WebSocket Controller» マウス キーボード タッチデバイス Fullscreen 有効 無効 jsdo.it games から削除する Submit Tweet style Design view Code view code <script type="text/javascript" src="http://jsdo.it/blogparts/lOgS/js?view=design"></script><p class="ttlBpJsdoit" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://jsdo.it/djakarta-trap/lOgS" title="掌田津耶乃(7歳)から学ぶJS DOM その1">掌田津耶乃(7歳)から学ぶJS DOM その1 - jsdo.it - share JavaScript, HTML5 and CSS</a></p> 掌田津耶乃(7歳) Tweet twitter Tags 掌田津耶乃(7歳) Forked sort new page view favorite forked forked from: 掌田津耶乃(7歳)から学ぶJS .. djakarta-tra.. 10 651views 21/8/1 掌田津耶乃(7歳)から学ぶJS DOM その2 djakarta-tra.. 00 323views 25/9/1 掌田津耶乃(7歳)