I am getting the following ReferenceError: Document is not defined when running my html code on Cloud 9
When running the javascript file, the following error appears:
ReferenceError: document not defined
I am bringing jquery into my project in html file like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
<script src = "http://code.jquery.com/jquery-2.1.1.js"></script>
<script src="javascript/index.js" type="text/javascript"></script>
</head>
<body>
<div class="indexHead">
<div id="logoDiv">
<p id="logo">Ada</p>
<p id="compName">Consulting</p>
<p id="parCompName">A Sorma Enterprises Company</p>
</div>
</div>
<div class="blocks">
<div id="redBlock">
<p id="socialContent">Social Content Marketing</p>
</div>
<div id="yellowBlock">
<p id="webAndAppDev">Website and Application Development</p>
</div>
<div id="blueBlock">
<p id="biContent">Business Intelligence</p>
</div>
</div>
<div class="indexFoot">
</div>
</body>
</html>
with the following javascript (jquery):
Can someone tell me where I am going wrong?
+3
source to share
1 answer
Try
<!doctype html>
See What_is_the_DOCTYPE_for_modern_HTML_documents , Choosing_the_right_doctype_for_your_HTML_documents
$(document).ready(function(){
console.log(jQuery().jquery)
$('#redBlock').click(function(){
alert('alert');
});
})
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
</head>
<body>
<div class="indexHead">
<div id="logoDiv">
<p id="logo">Ada</p>
<p id="compName">Consulting</p>
<p id="parCompName">A Sorma Enterprises Company</p>
</div>
</div>
<div class="blocks">
<div id="redBlock">
<p id="socialContent">Social Content Marketing</p>
</div>
<div id="yellowBlock">
<p id="webAndAppDev">Website and Application Development</p>
</div>
<div id="blueBlock">
<p id="biContent">Business Intelligence</p>
</div>
</div>
<div class="indexFoot">
</div>
</body>
</html>
+1
source to share