Days 1
JavaScript is the world's most popular programming language.
JavaScript is the programming language of the Web.
JavaScript Can Change HTML Content
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="test">JavaScript can be change HTML content as well as.</p>
<button type="button" onclick='document.getElementById("test").innerHTML = "Hello JavaScript Whats going on !"'>Click Me Now !</button>
</body>
</html>
JavaScript Where To
In HTML, JavaScript code is inserted between <script> and </script> tags.
Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.
1. <script>
2. <head>
3.<body>
JavaScript use in <HEAD>
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "ankita .";
}
</script>
</head>
<body>
<p id="demo">want to know name of girl </p>
<button type="button" onclick="myFunction()">Yes!!!</button>
</body>
</html>
JavaScript use in <BODY>
<!DOCTYPE html>
<html>
<body>
<h2>Demo JavaScript in Body</h2>
<p id="demo">Want to know about girl name .</p>
<button type="button" onclick="myFunction()">Yes!!!!</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Ankita .";
}
</script>
</body>
</html>
JavaScript Display Types
JavaScript can "display" data in different Types:
using innerHTML.
using document.write().
using window.alert().
using console.log().
using prompt().
using window.print().
inner.HTML
<!DOCTYPE html>
<html>
<body>
<p id="test"></p>
<script>
document.getElementById("test").innerHTML = 12 + 12;
</script>
</body>
</html>
using document.write().
<!DOCTYPE html>
<html>
<body>
<script>
document.write(12+12);
</script>
</body>
</html>
using window.alert().
<!DOCTYPE html>
<html>
<body>
<script>
window.alert(5 + 6);
</script>
</body>
</html>
using window.print()
<!DOCTYPE html>
<html>
<body>
<button onclick="window.print()">Print this page</button>
</body>
</html>

0 Comments