JS - Syntax
JavaScript का code script tag के बीच में लिखा जाता हैं, और script tag को हम HTML में head tag और body tag में कही भी implement किया जा सकता हैं|
Script Tag
script tag में type नाम का एक attribute use किया जाता हैं जिस पर "text/javascript" लिखा जाता हैं, JavaScript का code सिर्फ script Tag में लिखा जाता हैं|
Syntax for JavaScript
<script type="text/javascript"> //some javascript statements; </script>
Q :- Write a JavaScript program to print 'Hello World'.
Source Code :
<!DOCTYPE html> <html> <head> <title>Hello World Program</title> <script type="text/javascript"> document.write("Hello World"); </script> </head> </html>
Output :-
Hello World
Q :- Write a JavaScript Program to Print biodata.
Source Code :
<!DOCTYPE html> <html> <head> <title>Biodata</title> </head> <body> <script type="text/javascript"> document.write("Name : Amit <br>"); document.write("Address : Raipur (C.G.) <br>"); document.write("Email Id : amit@gmail.com <br>"); document.write("Mobile Number : 7856987453 <br>"); </script> </body> </html>
Output :-
Name : Amit Address : Raipur (C.G.) Email Id : amit@gmail.com Mobile Number : 7856987453
Post a Comment
If you have any doubts,Please let me know