Javascript Detailed Description

0

It is a client-side script that is used to perform the dynamic operation under an HTML Web page. HTML only provides a set of elements and attributes, CSS provides a set of properties and Javascript provides dynamic code, client-side logic development, validation and animation in the HTML web page.
Javascript can be executed in any Web Browser as compare to other scripts.
Syntax of JavaScript:-
We can write JS Code into two different ways:-
1)  Under HTML Web page in <head></head> using <script>  </script> tag
   example of internal JS:-
   <!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript">
       
        alert("welcome in JS");
    </script>
</head>
<body>
   <h1>Welcome in HTML</h1>
</body>
</html>
2)  Create separate file for .js and link under web pages
    <script src="filename"  ></script>
  Create Separate File script.js
 alert("welcome in JS");
  Create .html file and call .js file under head section
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="script.js"></script>
</head>
<body>
<h2>Welcome in SCS</h2>
</body>
</html>
Javascript code based on event:-
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript">
        function fun()
        {
            alert("welcome in JS");
            document.getElementById("b").bgColor='cyan';
        }        
    </script>
</head>
<body id="b">
   <h1>Welcome in HTML</h1>
   <input type="button" onclick="fun()" value="Click" />
</body>
</html>
Tags

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)