Reputation: 29
I'm trying to create a simple website using basic java script but I think i'm not able to call to the file correctly have tried multiple sources online but to no success. Can you have a look at my code and tell me what's wrong ?
html:
<html>
<head>
<script src="js/js1.js" type="text/javascript"></script>
</head>
The total number of square feet in your house is:<br>
<script src="js/js1.js">test()</script>square feet.
js:
function test() {
var test = 15;
document.write(test);
return test;
}
Upvotes: 0
Views: 94
Reputation: 4129
Base on @MoustafaS's answer, your js file can be fixed:
function test() {
var test = 15;
document.write(test);
return test;
}
Then call it in HTML:
<script>test()</script>
Upvotes: 0
Reputation: 535
I think you have put an >
after test()
for which there is an Uncaught SyntaxError: Unexpected end of input
<script src="js/js1.js">test()></script>square feet.
<head>
<script>
function test() {
var test = 15;
document.write(test);
return test;
}
</script>
</head>
<body>
The total number of square feet in your house is:<br>
<script>test()</script> square feet.
Upvotes: 1
Reputation: 2031
This:
<script src="js/js1.js">test()></script>
Should be:
<script>test()</script>
Upvotes: 3