
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
JavaScript Syntax with Demonstration Code
JavaScript Tags
The html script tag wants the browser to get a script between them. We can expect the scripts to be in the following places.
1.The script can be placed in html's head tag
2.Within Html's body tag.
3.As an external file.
Most importantly client side scripts such as JavaScript are placed in script tags.
demonstration code
<html> <body> <p>This example writes "JavaScript is not java" into an HTML element with id="script"</p> <p id="imp"></p> <script> document.getElementById("imp").innerHTML = "JavaScript is not java"; </script> </body> </html>
Output
This example writes "JavaScript is not java" into an HTML element with id="script" JavaScript is not java
Explanation
Every JavaScript code should be in the script tag, if not the code wont execute.In the above example using attribute id the code has executed as "JavaScript is not java".
Advertisements