尝试时,我得到一个"ReferenceError:文档未定义"
var body = document.getElementsByTagName("body")[0];
Run Code Online (Sandbox Code Playgroud)
我之前在其他代码中看过这个,并没有造成任何麻烦.为什么现在呢?随之而来的HTML页面只是体内的一个div.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/quiz.css" />
<script type="text/javascript" src="js/quiz.js"></script>
</head>
<body>
<div id="divid">Next</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
代码如下:
(function(){
var body = document.getElementsByTagName("body")[0];
function Question(question, choices, correctAns) {
this.question = question;
this.choices = choices;
this.correctAns = correctAns;
}
Question.prototype.checkAns = function(givenAns){
if (this.correctAns === givenAns) {
console.log("OK");
}
};
function Quiz() {
this.questions = [];
}
Quiz.prototype.showAllQuestions = function(){
this.questions.forEach(function(questions){
console.log(questions.question);
});
};
Quiz.prototype.showQuiz = function(){
this.questions.forEach(function(questions){
for (var …Run Code Online (Sandbox Code Playgroud) 嗨,我是OOP的新手,所以在阅读本文时请记住这一点.
我有一个简单的Python树实现(见下面的代码).
class TreeNode(object):
def __init__(self, data):
self.data = data
self.children = []
def add_child(self, obj):
self.children.append(obj)
class Tree:
def __init__(self):
self.root = TreeNode('ROOT')
def preorder_trav(self, node):
if node is not None:
print node.data
if len(node.children) == 0:
print "("+ node.data + ")"
for n in node.children:
self.preorder_trav(n)
if __name__ == '__main__':
tr = Tree()
n1 = tr.root
n2 = TreeNode("B")
n3 = TreeNode("C")
n4 = TreeNode("D")
n5 = TreeNode("E")
n6 = TreeNode("F")
n1.add_child(n2)
n1.add_child(n3)
n2.add_child(n4)
n2.add_child(n5)
n3.add_child(n6)
tr.preorder_trav(n1)
Run Code Online (Sandbox Code Playgroud)
我现在需要的是实现一个获取Leaf …
我想分析一下QEMU如何模拟支持的网络设备读取源代码。另外我想与我分享一下您对理解 QEMU 源代码需要什么背景的看法。请向我推荐一些围绕主题的好书或在线资源,为了实现这一目标,人们必须学习这些主题(我想需要设备驱动程序、处理器规范等?)。另外,如果你能告诉我用 C 语言应该达到的编程水平(因为源代码是用 C 语言编写的),那就太好了。
我已经浏览过 QEMU 的网站,其中提供的内容主要涉及如何使用 QEMU 和配置它。