Difference between revisions of "Web defacing"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
= Snippets = | = Snippets = | ||
== HTML == | == HTML == | ||
+ | <syntaxhighlight lang="html"> | ||
+ | |||
+ | </syntaxhighlight> | ||
== CSS == | == CSS == | ||
+ | <syntaxhighlight lang="css"> | ||
+ | |||
+ | </syntaxhighlight> | ||
== JavaScript == | == JavaScript == | ||
+ | |||
+ | === Grabbing an element === | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | const titleElement = document.getElementById("my-title"); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Editing the content === | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | titleElement.innerHTML = "🙃" | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Creating an element === | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | const newListItem = document.createElement("li"); | ||
+ | // Set the content | ||
+ | newListItem.innerHTML = "Add an element using JavaScript"; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Insert an element === | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | // Grab the element that we want to insert the new element into. | ||
+ | const list = document.getElementById("my-list"); | ||
+ | // Append the new element | ||
+ | list.appendChild(newListItem); | ||
+ | </syntaxhighlight> | ||
+ | |||
= Resources = | = Resources = |
Revision as of 07:51, 24 April 2024
Snippets
HTML
CSS
JavaScript
Grabbing an element
const titleElement = document.getElementById("my-title");
Editing the content
titleElement.innerHTML = "🙃"
Creating an element
const newListItem = document.createElement("li");
// Set the content
newListItem.innerHTML = "Add an element using JavaScript";
Insert an element
// Grab the element that we want to insert the new element into.
const list = document.getElementById("my-list");
// Append the new element
list.appendChild(newListItem);