Академический Документы
Профессиональный Документы
Культура Документы
berbasis Internet
Javascript: Client-Side
Scripting
Dany Laksono
Week 4
Question:
What is the connection between HTML, CSS and
Javascript?
Department of
GEODETIC ENGINEERING | Gadjah Mada University
HTML, CSS and JS
<div id=“kucing>
<style>
#kucing {
warnaBulu: hitam;
panjangEkor: 4cm}
</style>
Department of
Kucing.bobo(“no”);
(membangunkan kucing yg bobo)
Kucing.tambahEkor(“200cm”);
(panjang ekor kucing ditambah 2
meter)
Department of
CSS
.biru {
color:blue
}
Ini tulisan warna biru
How? Examples
<style>
2 Embed in HTML #kucing {color:purple}
GEODETIC ENGINEERING | Gadjah Mada University
</style>
#para1 {
p { text-align: center;
text-align: center; color: red;
color: red; }
}
Class selector
.center {
text-align: center;
color: red;
}
Selective selector
p .center {
text-align: center;
color: red;
}
Grouping selector
h1, h2, p {
text-align: center;
color: red;
}
Praktek 2:
Buat sebuah halaman web dengan HTML dan CSS sehingga menghasilkan
tampilan seperti berikut:
Konsep dan latihan js coding
JS BASICS
12
JS Framework and Library
JS BASICS
19
Explain these terms below:
How? Examples
<style>
2 Embed in HTML #kucing {color:purple}
</style>
<script>
2 Embed in HTML window.alert(‘peringatan!’);
</script>
<button type="button"
onclick="document.getElementById('demo').inne
3 Inline html tag rHTML = Date()">
Click me to display Date and Time.</button>
$.getScript("myscript.js", function(){
Import from other
Department of
4 JS
alert("Script loaded and executed.");
});
Object, Properties and Methods in JS
Properties are values associated with objects
Methods are actions that objects can perform
Object Properties Methods
car.color = white
around it
Event: It’s Raining!
<!DOCTYPE html>
<html>
<body>
<h1>What Can JavaScript Do?</h1>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button"
onclick="document.getElementById('demo').innerHTML =
'Hello JavaScript!'">
Click Me!
</button>
</body>
</html>
HTML Document Object Model (DOM)
Function
var x = myFunction(4, 3);
function myFunction(a, b) {
return a * b;
}
Conditional ‘if’
‘For’ loop
if (hour < 18) {
for (i = 0; i < cars.length; i++)
greeting = "Good day";
{
} else {
text += cars[i] + "<br>";
greeting = "Good evening";
}
}
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
-- Decrement
Assigment Operators
Operator Example Same As
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
Examples on javascript-powered webpage
JAVASCRIPT DEMO
33
What you can do with JS?
http://www.queness.com/post/12139/8-visually-
impressive-javascript-powered-websites
http://tutorialzine.com/2013/09/20-impressive-
examples-for-learning-webgl-with-three-js/
What you can do with JS?
https://www.chromeexperiments.com/
What you can do with JS?
http://mrdoob.github.io/three.js/examples/css3d_periodictable.html
What you can do with JS?
http://wagerfield.github.io/parallax/
What you can do with JS?
http://ogreen.special-t.com/en/
What you can do with JS?
http://helloracer.com/racer-s/
What you can do with JS?
http://middle-earth.thehobbit.com/
What you can do with JS?
wellcaffeinated.net/PhysicsJS
What you can do with JS?
http://threejs.org/
What you can do with JS?
http://space.angrybirds.com/launch/
Department of
GEODETIC ENGINEERING | Gadjah Mada University
Menggunakan fungsi
Department of
GEODETIC ENGINEERING | Gadjah Mada University
Handling Event
Department of
GEODETIC ENGINEERING | Gadjah Mada University
Fungsi faktorial
Department of
GEODETIC ENGINEERING | Gadjah Mada University
58