Skip to content

Instantly share code, notes, and snippets.

@retronav
Last active May 10, 2020 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retronav/d24b78593b6fb7b6dd94728162025087 to your computer and use it in GitHub Desktop.
Save retronav/d24b78593b6fb7b6dd94728162025087 to your computer and use it in GitHub Desktop.
DOM manipulation problem while using TeddyTags

The Problem

If you are having problems with DOM manipulation, simply add all your DOM manipulation scripts as well as the TeddyTags declaration script with the defer attribute.

Working example with files attached.

let lol = document.querySelector("#lol");
lol.addEventListener("click", () => {
alert("Event Listener working");
});
let text = document.createElement("myHeader");
text.innerHTML = " Appended me??";
document.querySelector("#myHeader").appendChild(text);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/teddytags"></script>
<script defer src="./event.js"></script>
</head>
<body>
<myHeader name="header">Hello World!</myHeader>
<lol>ClICK</lol>
<script src="./tags.js"></script>
</body>
</html>
new Tag({name: 'myHeader', to: "h1"})
new Tag({name: 'lol', to: 'button'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment