07.08.2015.JavaScript / js
.pdfJava Script
Questions
●What is js designed for?
●What do you need to know to work with js?
●How does it works?
What is js designed for?
●Java script is a programming language which is most commonly used as part of web browser to interact with the user and alter the document content which is displayed.
●Java script also used for web, game development, mobile and desktop applications.
What is js designed for?
●Interaction
●Validation
●Motion
●Calculations
●Graphics etc.
Required skills
●HTML
●CSS
How does js works
●Web-client fetches a script
●Waits for event
●Executes a script
Js example
<!DOCTYPE html> <html>
<body>
<h1>JavaScript Can Change Images</h1>
<img id="myImage" onclick="changeImage()" src="ball1.jpg" width="128" height="128">
<p>Click the ball to change it's color.</p> </body>
</html>
Js example
<script>
var count = 1;
function changeImage() { count = count++ % 3 + 1;
var image = document.getElementById('myImage'); image.src = "ball" + count + ".jpg";
}
</script>
Js example
<!DOCTYPE html> <html>
<body>
<h1>JavaScript Can Change Images</h1>
<img id="myImage" onclick="changeImage()" src="ball1.jpg" width="128" height="128"> <p>Click the ball to change it's color.</p>
<script>
var count = 1;
function changeImage() { count = count++ % 3 + 1;
var image = document.getElementById('myImage'); image.src = "ball" + count + ".jpg";}
</script>
</body>
</html>
Js example
<!DOCTYPE html> <html>
<head>
<script type="text/javascript" src="balls-script.js"></script> </head>
<body>
<h1>JavaScript Can Change Images</h1>
<img id="myImage" onclick="changeImage()" src="ball1.jpg" width="128" height="128">
<p>Click the ball to change it's color.</p> </body>
</html>