**目次 [#rcea8c4c]
#contents
** DOMの勉強 [#o4855621]
|カテゴリー|DOMの勉強|
|優先順位|至急|
|イテレーション|[[イテレーション1]]|
|状態|未着手|
|完了予定日||
|状態|完了|
|完了予定日| 2007/8/28|
|工数||
|対応者|清原|
----
**HTML [#t2831939]
<html>
<head>
</head>
<body><div class='hoge'>
<div>テキスト: <span class='fuga'>aaa</span>
<form> <input type='text' id='user_input'></input>
<input type='button' value='click me!' />
</form> </div>
</div>
<pre>
** 課題 [#va613069]
- http://www.htmq.com/html/script.shtmlの<script src='hogehoge.js'>のような
書き方を使って、外部javascriptファイルを用意してその中で、次の処理を実行する
++ 「click meボタン」をclickすると、
1. クリックされたそのボタンの位置から、DOMで移動して、「aaa」の内容をテキスト ボックスに入力された内容に変更する
2. 同様に、<span>タグのclass 「fuga」を 「hoge」に変更する
3. 30秒後にgoogle.co.jpに表示中のページのURLを変更する。
</pre>
</body></html>
**プログラム [#g0854a8f]
var Kadai8 = function(){
window.onload = this.bindWindowOnLoad;
}
Kadai8.prototype = {
bindWindowOnLoad: function () {
var inputs = document.getElementsByTagName('input');
inputs[1].onclick = kadai.bindButtonOnClick;
},
bindButtonOnClick: function() {
text = document.getElementById('user_input');
this.parentNode.parentNode.childNodes[1].firstChild.nodeValue = text.value;
tag = document.getElementsByTagName('span');
tag[0].className = 'hoge';
console.debug(window.setInterval(kadai.jumpLocat,30000));
},
jumpLocat: function(){
window.location = "http://www.google.co.jp";
}
}
var kadai = new Kadai8();