I have written a function which prints a certain area of the DOM which is triggered by a button click which is rendered via JavaScript. See the below code...
function MarkQuiz() {
var CorrectAnswers = 0,
TotalQuestions = 0,
CurrentQuestion = "",
Percentage = 0,
Output = "";
$("select").each(function(key,value) {
CurrentQuestion = "#" + $(value).attr("id");
TotalQuestions = key + 1;
if($(CurrentQuestion).val() == "Correct") {
CorrectAnswers++;
}
});
Percentage = (CorrectAnswers / TotalQuestions) * 100;
Output = "You Scored..." +
"<h1>"+Percentage+"%</h1>" +
"Which means you got " + CorrectAnswers + " out of " + TotalQuestions + " correct.<br/>" +
"<br/><a href='#' onclick='PrintCertificate('#QuizMainContent')' class='button' id='PrintCertificate'>Print your Certificate</a>";
$("#QuizMainContent").html(Output);
}
function PrintCertificate(DOMArea) {
var PrintArea = $(DOMArea),
PrintWindow = window.open('','');
PrintWindow.document.write($(PrintArea).html());
PrintWindow.document.close();
PrintWindow.focus();
PrintWindow.print();
PrintWindow.close();
}
However, when I click that button, I receive this error...

This is the URL to the project: http://historicalperiods.esy.es/
What I am doing wrong? Thanks in Advance.
onclick='PrintCertificate('#QuizMainContent')'quotes?bohQuiz.html