where can you write javascript code ?
we can write javascript code :
- Any where in the HTML file between <script> </script> tags .
- As the value of the event handler attributes.
- writing js code Between <script> </script> tags , it may be internal or external .
- external by using src attribute in the script open tag <script> .
External JavaScript code Advantages :
- It separates HTML and code.
- It makes HTML and JavaScript easier to read and maintain.
- Cached JavaScript files can speed up page loads.
Note :
- Placing scripts at the bottom of the <body> element improves the display speed, because script interpretation slows down the display.
- we can write HTML mark ups inside js code by writing these HTML tags as a string , between " " double qoutes .
- Old JavaScript examples may use a type attribute: <script type="text/javascript"> ,The type attribute is not required. JavaScript is the default scripting language in HTML.

Comments
Post a Comment