開発環境
- OS X Lion - Apple(OS)
- Safari (Webプラウザ)
- TextWrangler(Text Editor) (BBEditの無料、light版)
- Script言語:JavaScript
- JavaScript Library: jQuery
『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリー・ジャパン、2009年、ISBN978-4-84311-425-5) の9章(ブラウザオブジェクトモデル)練習問題9-3解いてみる。
その他参考書籍
- JavaScript 第5版 David Flanagan (著), 村上 列 (翻訳)
- JavaScriptクイックリファレンス David Flanagan (著), 木下 哲也 (翻訳), 福龍興業 (翻訳)
- 『jQueryクックブック』(jQuery Community Experts 著、株式会社クイープ 訳、オライリー・ジャパン、2010年、ISBN978-4-87311-468-2)
9-3.
コード(TextWrangler)
var img = document.createElement("img"); img.id = 'img0'; $('#d0').append(img); var tmOut = setInterval(nextPic,5000); var photos = ["http://farm8.staticflickr.com/7261/7406369886_1a82c8c5c0.jpg", "http://farm8.staticflickr.com/7016/6504882499_4ef93d1a45.jpg", "http://farm5.staticflickr.com/4032/5120980604_130500eb87.jpg"] var currentPhoto = 0; function changePhoto(photo){ $('#img0').attr('src',photos[photo]); } function nextPic(){ if(currentPhoto < photos.length){ changePhoto(currentPhoto); } else { currentPhoto = 0; changePhoto(currentPhoto); } currentPhoto++; }
0 コメント:
コメントを投稿