JavaScript Syntax

JavaScript Syntax


JavaScript Syntax

JavaScript Syntax can be implemented using JavaScript code that is put inside the script tag that is like <script>… </script> HTML tags in web pages.

You can put the JavaScript code which is <script> place this code on anywhere into your web pages but normally this tag is used within the <head> tags.

The JavaScript tag <script> tells the browser to start interpreting all the text between these tags are called script.

Code Example

<script …>
JavaScript code
</script>

Two Most Important Attributes of <script>

  • Language- This Attribute specifies the scripting language which you are using. Normally this value will be javaScript the recent versions of HTML and XHTML, have staged out the use of this attribute.
  • Type- This attribute is currently used to show the scripting languages and its value should be in a form of text/javascript.

Let’s take an example of a print “Hello JavaScript”. To print this we need to add an HTML tag that surrounds our JavaScript code. This tag is used to save our code from a browser that does not support JavaScript. For the End of the comment, you need to use “//–>”. here “//” signifies a comment in JavaScript, so we need to add that anticipate a browser to read the HTML comment as a JavaScript code.

Now here is a Sample of HTML comment:

<html>
<body>
<script language = “javascript” type = “text/javascript”>
<!–
document.write(“Hello JavaScript”)
//–>
</script>
</body>
</html>

This Code will produce a output of the following.

Hello JavaScript


 

 

Leave a Reply

Your email address will not be published. Required fields are marked *