JavaScript Introduction

      No Comments on JavaScript Introduction

JavaScript Introduction

JavaScript Introduction

What is JavaScript

JavaScript is popular Client Side scripting language basically used for many purpose including validation.

Where you can use JavaScript ?

JavaScript can be used for validation purpose.

JavaScript can be used to check blank fields before form can be submitted.

Hello World JavaScript using Document.Write() : This method is used to display some string on client browser.

<!DOCTYPE html>
<html>
<body>
    <script>
      document.write("Hello...");
    </script>
</body>
</html> 

 

Hello World JavaScript using alert() : This method is used to display message to user.

<!DOCTYPE html>
<html>
<body>
     <script>
          alert("Hello...");
     </script>
</body>
</html> 

 

Hello World JavaScript using getElementById() : This method is generally used to paste more data into Division Tag or Paragraph.

<!DOCTYPE html>
<html>
<body>
<div id="detail"> </div>
<script>
     document.getElementById("detail").innerHTML = "Adarsh Patel";
</script>
</body>
</html> 

 

How to Declare Variable in JavaScript
To declare Variable in Javascript var keyword is used. eg. var name=”Adarsh Patel”;

Is JavaSctipt Case Sensitive ?

Yes

 

Which operator is supported by JavaScript?

Almost all Operators which is available in C Like Language is supported by JavaScript.

 

How to Declare Button and Function in JavaScript ?

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
    document.getElementById("detail").innerHTML = "Wow it's Working fine !!!";
}
</script>
</head>
<body>
<input type="button" onClick="myFunction()" value="Click Here">
<div id="detail"> </div>
</body>
</html> 

 

Display Variable Value along with How to Contact Two String:

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
    <script>
        var myname = "Adarsh Patel";
        document.getElementById("demo").innerHTML = "My Name is : " + myname;
     </script>
</body>
</html>

.

Leave a Reply