Reputation:
Why the alert message is not being displayed ??
This is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery demo</title>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
$(document).ready(function(){
alert("Hi welcome to Jquery ");
}
);
</script>
</body>
</html>
Upvotes: 1
Views: 24354
Reputation: 117
$(document).ready(function(){
alert("Hi welcome to Jquery ");
});
is working fine.
My problem was the Firefox "screen-size-test" option. I tested for mobile version but the JS-Alert box was not displayed in the middle of the "screen-size test" but in the middle of screen itself, which became invisible due to the overlay of this option
Upvotes: 0
Reputation: 7954
Change your script section to this
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
alert("Hi welcome to Jquery ");
}
);
</script>
Upvotes: 2
Reputation: 5201
In my browser it works. Try making the following improvements to make it more compliant:
1) Add the attribute type="text/javascript"
to your script
tags.
2) Move the scripts to the head
part of the document.
PS: You can use the following shorthand notation to have a function called when the document finishes loading:
$(function(){
alert("Hi welcome to Jquery ");
});
Upvotes: 2
Reputation: 1768
When I run this it does display the alert message, but what you may be experiencing is a race condition with loading the jQuery framework and using it in the body
of the page. Try moving the script
tag that loads jQuery into the head
area of the page. This will make sure jQuery has loaded before the DOM tries to use it.
Upvotes: 0
Reputation: 31033
check if the jquery is loaded or not by
if (typeof jQuery == 'undefined') {
console.log("jQuery is not loaded");
//or
alert("jQuery is loaded");
} else {
console.log("jQuery is not loaded");
alert("jQuery is not loaded");
}
Upvotes: 0