You are on page 1of 18

T

P
I
R
C
S
A
V
JA
CHUNGNN

NI DUNG
Tng quan v JS
S dng JS trong trang HTML
Ngn ng lp trnh JS
Mt s v d s dng JS

TNG QUAN
Hng i tng, hng s kin
Thng dch
Ngn ng lp trnh pha client, s dng tng tc vi trang
HTML
Hin nay c h tr bi cc trnh duyt v rt ph bin

A JS VO TRANG HTML
Chn JS vo th head
Chn JS vo trc th </body>
Chn vo s kin
<script type=text/javascript> </script>
<script type=text/javascript src=></script>
<a onclick=doSomething();></a>

NGN NG JS
Bin
Ton t
R nhnh, lp
Hm, truyn tham s cho hm, callback
i tng
Cc i tng, hm c sn

BIN, KIU D LIU


S
Boolean
Chui
Null & Undefined
Mng
i tng

TON T
Gn =
S hc: +, -, *, /, %, ++, -+=, -=, *=, /= %=
So snh: ==, !=, >, <, >=, <=
Logic: &&, ||, !
Ton t ? :

R NHNH
If, if else
Switch case

LP
For
For(i=0;i<n;i++)
For(x in array), for(x in object)
While

HM
Khai bo hm
Truyn tham s
Callback

I TNG
Hm l mt i tng
S dng con tr this

MT S HM DNG SN
Alert, confirm
parseInt
isNaN
Typeof
setTimeout, setInterval, clearTimeout, clearInterval

CC I TNG C SN
Window, document, console
Math, Date, Array, String

JS V HTML

JS V HTML
Thao tc ln i tng trn JS s lm thay i vic hin th trn
trang html
X l cc s kin

DNG JS TC NG LN THNH
PHN HTML
Var el = document.getElementById(test);
El.innerHTML = xyz

X L S KIN
Onclick, ondbclick, onmousedown, onmouseup, onmousemove,
onmouseover, onmouseout
Onkeydown cho phm bt k, onkeyup, onkeypress cho phm
c th hin th
Onsubmit dnh cho form
Onload, onunload dnh cho document (body)

V D X L S KIN
<button onclick=alert(hello)>Hello</button>

You might also like