loading - Javascript file will not load -
i have simple script works when included in html body. however, when running relative path, , including
<script type="text/javascript" src="simple.js"></script> in either header or bottom of html file, script no longer run.
can point missing ?
thank you.
script simple.js:
<script> function firstfunction(){ var = document.getelementbyid("firstinput").value; if(! a){ alert("minimum input of 1 char required"); }else{ document.getelementbyid("firstoutput").innerhtml=a; } } function secondfunction(){ var b = document.getelementbyid("secondinput").value; if(!b){ alert("minimum input of 1 char required"); } document.getelementbyid("secondoutput").innerhtml=b; //document.getelementbyid("secondoutput").innerhtml = "updated!"; }
you need <script> tag if include javascript html file.
in .js file, it's syntax error. write javascript code without tag!
file simple.js:
function firstfunction(){ var = document.getelementbyid("firstinput").value; if(!a){ alert("minimum input of 1 char required"); }else{ document.getelementbyid("firstoutput").innerhtml=a; } } function secondfunction(){ var b = document.getelementbyid("secondinput").value; if(!b){ alert("minimum input of 1 char required"); } document.getelementbyid("secondoutput").innerhtml=b; //document.getelementbyid("secondoutput").innerhtml = "updated!"; } as file right now, make sure place script right before closing body tag
<script type="text/javascript" src="simple.js"></script> </body> so elements can found when script running.
Comments
Post a Comment