Code:
<!DOCTYPE html>
<head>
<script type="text/javascript" src="jquery-3.3.1.js">
</script>
<script type="text/javascript">
$(function() {
alert("Hello World");
});
</script>
<meta charset="utf-8">
<link href="../style/Home.css">
</head>
<body>
<input type="text" name="username" placeholder="Username" id="user" />
<input type="password" name="password" placeholder="password" id="pass" />
<input type="submit" id="submitButton">
</body>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
The html section of the code, like the input fields works fine, but the javascript portion has not been working. Originally I had it where the javascript portion of the code was its own separate file, but I ultimately had to change that when it wasn't working. Even after I added the javascript code to the html file the code still wouldn't run, so I just did a generic alert statement to see if the problem was with the javascript code or if it was something else.
CodePudding user response:
in you browse press F12 > Network > make sure Disable cache has checked
you should type alert() only
<script>
alert();
</script>
alert will still run even if jquery is not read
CodePudding user response:
path to your jquery file is invalid.
<script type="text/javascript" src="jquery-3.3.1.js">
in src, you cannot give path like this: jquery-3.3.1.js. give proper path.