HTML (index.html):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> < html xmlns = "http://www.w3.org/1999/xhtml" lang = "zh-TW" xml:lang = "zh-TW" > < head > < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" /> < title >Hello JavaScript</ title > < style > a:hover { background: yellow; } </ style > < script type = "text/javascript" > function hello() { document.getElementById("codeboxy").innerHTML += "Hello JavaScript< br />"; } </ script > </ head > < body > < a href = "javascript:hello();" >Click me</ a > < div id = "codeboxy" ></ div > </ body > </ html > |
簡單展示HTML架構下如何使用CSS、JavaScript,
CSS展示當滑鼠移動到標籤a上則將文字背景顏色更換,
JavaScript展示當點擊超連結則在id為codeboxy的div標籤內增加字串。
沒有留言:
張貼留言