Академический Документы
Профессиональный Документы
Культура Документы
What is JavaScript ?
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
JavaScript Can Change HTML Attribute Values
In this example JavaScript changes the value of the src (source) attribute of an <img> tag:
<p>In this case JavaScript changes the value of the src (source) attribute of an image.</p>
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">
Turn on the light</button>
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">
Turn off the light</button>
</body>
</html>
JavaScript Where To
The <script> Tag
<script>
Javascript code……
</script>
JavaScript Functions and Events
function clickMe() {
javascript code…….
}
JavaScript in <head> or <body>
JavaScript in <head>
JavaScript in <body>
External JavaScript
<script src=“myScript.js”></script>
JavaScript Variables
<h2>JavaScript Variables</h2>
<p id="demo"></p>
<script>
var x;
x = 6;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>