I noticed on my website that jQuery stops working but I get no error on the console. I have been trying to test it with very basic code but still the jquery library is loading well, the javascript code works but not the jQuery. I tested it with Chrome and Internet Explorer on two different puters. Could someone point me to a direction to look for this problem please ?
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src=".1.3/jquery.min.js"/>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<h1>JQuery</h1>
<p>hide me please</p>
<p id="demo">demo</p>
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
</body>
</html>
I noticed on my website that jQuery stops working but I get no error on the console. I have been trying to test it with very basic code but still the jquery library is loading well, the javascript code works but not the jQuery. I tested it with Chrome and Internet Explorer on two different puters. Could someone point me to a direction to look for this problem please ?
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/2.1.3/jquery.min.js"/>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<h1>JQuery</h1>
<p>hide me please</p>
<p id="demo">demo</p>
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
</body>
</html>
Share
Improve this question
asked Feb 21, 2015 at 14:14
HuguesHugues
3651 gold badge3 silver badges11 bronze badges
3
- Try getting jquery file on your local system instead of referring from external URL – Wasim Wani Commented Feb 21, 2015 at 14:16
- Yep, I have tried that too. Same problem. – Hugues Commented Feb 21, 2015 at 14:17
-
2
You cannot use the "self-closing" syntax (
/>
) to close<script>
elements. Some browsers will ignore the other scripts in the document when you do that.<iframe>
works the same way. – Frédéric Hamidi Commented Feb 21, 2015 at 14:17
3 Answers
Reset to default 8Try using
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/2.1.3/jquery.min.js"></script>
Instead of
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/2.1.3/jquery.min.js"/>
And let us know if it solved the issue or not. <script>
tag is not supposed to be self-closed.
The problem is with
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/2.1.3/jquery.min.js"/>
this line.
Please remove /
and close tag in a way </script>
. Should work.
I guess the jquery script tag should be closed normally. As far as I know script tags are not self closing. I might be wrong though.