PROJECT CODE

                                            The Developers Choice!!!!
                                                                                                            Home | About Us | Contact Us

HTML TUTORIALS

Lecture24 : Javascript

What is HTML Javascript
Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities. JavaScript is used in Web site development to do such things as:

- Automatically change a formatted date on a Web page.
- Cause a linked-to page to appear in a popup window.
- Cause text or a graphic image to change during a mouse rollover.
How to use Javascript
Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side functionality in the user's browser without having to make calls back to the server; thus, saving resources.

<!DOCTYPE html>
<html>
<body>
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click me.</button>
<p id="demo"></p>
</body>
</html>

How to implement Javascript
Display Date & Time using javascript?

<!DOCTYPE html>
<html>
<body>
<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
Click me.</button>
<p id="demo"></p>
</body>
</html>

Output :



How to use <script> tag
The HTML <script> tag is used for declaring a script (such as JavaScript) within your HTML document.The <script> tag either use scripting statements, or it use an external script file through the src attribute. Commonly uses of <script> tag are image manipulation, form validation, and dynamic changes of content. To select an HTML element, JavaScript very often use the document.getElementById(id) method. This <script> tag example writes "Hello JavaScript!" into an HTML element with id="demo1":

<!DOCTYPE html>
<html>
<body>
<p id="demo1"> </p>
<script>
document.getElementById("demo1").innerHTML = "Hello JavaScript!";
</script>
</body>
</html>

Output :

How to change content

<!DOCTYPE html>
<html>
<body>
<p>JavaScript can change the content of an HTML element:</p>
<button type="button" onclick="myFunction()">Click Me!</button>
<p id="demo2">This is a demonstration.</p>
<script>
function myFunction() {
document.getElementById("demo2").innerHTML = "Hello JavaScript!";
}
</script>
</body>
</html>
Output :

JavaScript can change the content :

This is a demonstration.

How to change Font size and color

<!DOCTYPE html>
<html>
<body>
<p id="demo3">JavaScript can change the style and Color.</p> <script> function myFunction() {
document.getElementById("demo3").style.fontSize = "20px";
document.getElementById("demo3").style.color = "blue";
} </script>
<button type="button" onclick="myFunction()">Click Me!</button>
</body>
</html>

Output :

JavaScript can change the style and Color.

   
All Rights Reserved with Project code