JAVA SCRIPT IN BRIEF
1. PARAGRAPH
BY ID
<!DOCTYPE html>
<html>
<body>
<h1>My Web
Page</h1>
<p
id="demo">A Paragraph.</p>
<script
type="text/javascript">
document.getElementById("demo").innerHTML="My
First JavaScript";
</script>
</body>
</html>
2. PARAGRAPH
BY DIRECT
<h1>My First Web
Page</h1>
<script
type="text/javascript">
document.write("<p>My
First JavaScript</p>");
</script>
3.
JavaScript Functions in <head>
<!DOCTYPE html>
<html>
<head>
<script
type="text/javascript">
function myFunction()
{document.getElementById("demo").innerHTML="My
First JavaScript Function";}
</script>
</head>
<body>
<h1>My Web
Page</h1>
<p
id="demo">A Paragraph.</p>
<button
type="button" onclick="myFunction()">Try
it</button>
</body>
</html>
No comments:
Post a Comment