I receive the following error ReferenceError: document is not defined when running my html code in Cloud 9
I receive the following error ReferenceError: document is not defined when running my html code in Cloud 9
我在运行 javascript 文件时收到以下错误:
ReferenceError: 文档未定义
我按以下方式将 jquery 引入 html 文件中的项目中:
<!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>
与以下 javascript(jquery):
$(document).ready(function(){
$('#redBlock').click(function(){
alert('alert');
});
});
谁能告诉我哪里出错了?
尝试
<!doctype html>
见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>
我在运行 javascript 文件时收到以下错误:
ReferenceError: 文档未定义
我按以下方式将 jquery 引入 html 文件中的项目中:
<!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>
与以下 javascript(jquery):
$(document).ready(function(){
$('#redBlock').click(function(){
alert('alert');
});
});
谁能告诉我哪里出错了?
尝试
<!doctype html>
见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>