Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Javascript Introduction:-  


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>


                                       

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post