I have a very simple jquery test page and I can't seem to get even the basics to work.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type=”text/javascript”>
$(function(){
alert('hi');
});
</script>
</head>
<body>
This is a test
</body>
</html>
Basically, I just want an alert box to pop up when the page is ready.
There are no errors on the page but the alert box doesn't show up. This seems to be a very, very simple page to me so I'm not sure what I'm missing. Does anyone have any ideas?
Couple of possible problems: missing DOCTYPE
and wrong quotes around type
attribute of the script
tag.
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function(){
alert('hi');
});
</script>
</head>
<body>
This is a test
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With