So I'm trying to gain a better understanding of JQuery and its use for web content and web applications so just hear me out here please. The goal of this test page is to be able to use the buttons to change, create, and delete content. Another goal is to test out the functionality of using the "enter" key to click one of the buttons from the text box (simulating user the enter key to click a submit button). This is the code that I developed and I'm a bit confused on how to fix the error of "destroyContent" is not defined. Obviously my syntax is off but I'm not sure how to fix it. Could anybody assist and possibly point me towards some useful reference material?
The JQuery:
$(document).ready(function () {
$('#Scan').keypress(keyHandler);
});
$.keyHandler = function (e) {
if (e.which == 13) {
$(this).blur();
$('#destroy').focus().click()
}
}
$.changeHeading1 = function () {
x = document.getElementById("Heading1")
x.innerHTML = "It has changed";
}
$.createContent = function () {
var para = document.createElement("p");
var node = document.createTextNode("This is new");
para.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(para);
}
$.destroyContent = function () {
var child = document.getElementById("p1");
child.parentNode.removeChild(child);
}
(I promise it looks a lot better in my actual code, I just have a hard time formatting on here)
For the HTML:
<h1 id="Heading1" />
<p id="p1" />
<button type="text" id="Scan" />
<button type="button" onclick="changeHeading1()" />
<button type="button" onclick="createContent()" />
<button type="button" id="destroy" onclick="destroyContent()" />
$when they make no use of jQuery at all?