The process to attach a JavaScript file with the html file is -----
- First you have to create a JavaScript code file.
- Save it with extension .js.
- Now create an HTML code file.
- Give the complete address of js file into script tag under src=" ".
- Save it with extension .html or .htm.
- Run HTML file.
Example:--
JavaScript Code:---
var m1,m2,m3;
m1=prompt("Enter the 1st no.:");
m2=prompt("Enter the 2nd no.:");
m1=parseInt(m1);
m2=parseInt(m2);
m3=m1+m2;
document.write("Addition is :" +m3);
HTML Code:---
Input:---
Output:---
Addition is 36.
No comments:
Post a Comment