Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
第07回Web講座2018
Search
北海道科学大学 電子計算機研究部
July 11, 2018
Education
0
52
第07回Web講座2018
北海道科学大学 電子計算機研究部
July 11, 2018
Tweet
Share
More Decks by 北海道科学大学 電子計算機研究部
See All by 北海道科学大学 電子計算機研究部
第12回Network講座2019
densan
1
61
第11回Network講座2019
densan
0
73
第10回Network講座2019
densan
0
48
第09回Network講座2019
densan
1
160
第08回Network講座2019
densan
0
52
第07回Network講座2019
densan
0
49
第06回Network講座2019
densan
0
74
第05回Network講座2019
densan
0
54
第04回Network講座2019
densan
0
120
Other Decks in Education
See All in Education
核軍備撤廃に向けた次の大きな一歩─核兵器を先には使わないと核保有国が約束すること
hide2kano
0
200
SJRC 2526
cbtlibrary
0
170
Semantic Web and Web 3.0 - Lecture 9 - Web Technologies (1019888BNR)
signer
PRO
2
3.1k
【dip】「なりたい自分」に近づくための、「自分と向き合う」小さな振り返り
dip_tech
PRO
0
210
Going over the Edge
jonoalderson
0
270
Introdución ás redes
irocho
0
510
The World That Saved Me: A Story of Community and Gratitude
_hashimo2
3
470
1202
cbtlibrary
0
190
The browser strikes back
jonoalderson
0
290
AIは若者の成長機会を奪うのか?
frievea
0
150
Linguaxes de programación
irocho
0
510
XML and Related Technologies - Lecture 7 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
390
Discover your Explorer Soul
emna__ayadi
2
1k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
43
The #1 spot is gone: here's how to win anyway
tamaranovitovic
1
880
Building AI with AI
inesmontani
PRO
1
610
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
170
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
120
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
74
How to train your dragon (web standard)
notwaldorf
97
6.5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
200
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
47k
Transcript
ネットワークチーム 第7回 北海道科学大学 電子計算機研究部
INDEX ⚫ オブジェクト ⚫ DOM ⚫ HTMLの操作 ⚫ 関数・メソッドの呼び出し 2
オブジェクト
オブジェクトとは JavaScriptのオブジェクトとは 名前(キー)と値のペア の集まり このペアをプロパティという 4 user1 name : ”Gouda”
age : 19 num : 2173056 user2 name : ”Kanda” age : 19 num : 2173068
オブジェクトの生成 JavaScriptでは オブジェクトを変数に入れることができる。 5 let name = { key1:value1, key2:value2
}; 構文 let name = new Object(); name.key1 = value1; name.key2 = value2;
オブジェクトへのアクセス オブジェクトの要素へアクセスするためには . (ピリオド)又は [“ ”] を使用する。 6 name.key1 =
value; 構文 name key1 : *** key2 : *** name key1 : value key2 : *** name[“key1”] = value;
書いてみよう 7
メソッド オブジェクトは関数を持つことができる。 このとき、オブジェクトの中の関数を メソッドという 8 let name = { method:function()
{ 処理; } }; 構文
書いてみよう 9
DOM
DOMとは Document Object Model HTMLの要素を、JavaScriptなどのプログラムから 操作するための仕組み HTML文書をツリー状の集合として扱う これをDOMツリーという DOMツリーでは HTMLの各タグや要素をノードと呼ぶ
11
第一回 演習2(再掲) document.getElementsByTagName(‘h1’)[0].innerHTML = (“NetTeam”); ↲Enter 12 JavaScript で HTML
の内容を 操作(書き換え) している
DOMツリー 13 <html> <body> <h1> <p> 見出し netteam <head> <title>
DOMツリー Document ノード
HTMLの操作 getElementsBy
getElementsBy – メソッド document(HTMLファイル)から 指定した条件を満たす要素を取得するメソッド 15 構文 用途 .getElementsByClassName(クラス名); 指定したクラスの要素を
配列で取得 .getElementsByName(name属性値); 指定したname属性値を持つ 要素を配列で取得 .getElementsByTagName(要素名); 指定したタグの要素を 配列で取得 .getElementById(ID名); 指定したID名を持つ要素を 取得(配列ではない)
書いてみよう 16
要素へのアクセス 取得した要素にアクセスするには 以下の方法がある 17 構文 用途 .innerHTML 要素にアクセス タグを含む .innerText
要素にアクセス タグを含まない .textContent .innerTextとほぼ同じ
書いてみよう 18 P16の続きから 文字が書き換えられた!
書いてみよう 19 添字を忘れずに
書いてみよう 20
要素の追加1 21
要素の追加2 22
関数・メソッドの呼び出し
ボタンによる呼び出し ボタンに関数を設定することで ボタンが押下されたときに関数を呼び出すことができる 24
書いてみよう 25
本日はここまで お疲れ様でした