JavaScript in HTML:

With the help of HTML you can create dynamic web pages but what about validation? So you can use JavaScript or VBScript to validate anything on your web page.

You can insert a JavaScript code in a HTML page for that <script> opening tag and </script> closing tag is used. JavaScript is a client side scripting language. All coding should be written in <script> tag.

We commonly use JavaScript for from validation.

Syantax:

<script>

<!—JS code goes here –>

</script>

Example:

The <noscript> tag in HTML:

The <noscript> tag is use to provide a alternative content because if the browser does not support JavaScript so this time the <noscript> tag will be used.

Example:

Following example will work when browser does not support JavaScript

 

How to Comment JavaScript:

You can also comment a JavaScript code by <!–   –> comment tags. Be sure when you comment JavaScript.

Example:

 

How to apply Styles, Attributes to JavaScript:

You can also apply style and attribute by JavaScript. With following examples you can understand how to apply styles and attributes to JS.

Example:

Changing HTML content by JavaScript

Example:

Changing HTML styles by JavaScript

Leave a Reply

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