mirror of
https://github.com/jlengrand/web-components-workshop-deprecated.git
synced 2026-03-10 08:51:23 +00:00
44 lines
1.6 KiB
HTML
44 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>WebComponents workshop</h1>
|
|
<p>In this workshop, we will create new custom HTML Components</p>
|
|
|
|
<hello-world></hello-world>
|
|
<hello-world-with-params name="Meetup"></hello-world-with-params>
|
|
<div>
|
|
<cat-img></cat-img>
|
|
</div>
|
|
<div>
|
|
<cat-img-fast></cat-img-fast>
|
|
</div>
|
|
<div>
|
|
<button onclick="removeHelloWorld()">Click me to remove Hello World</button>
|
|
</div>
|
|
<div>
|
|
<input type="text" id="hello-world-param">
|
|
<button onclick="changeHelloWorldParam()">Click me to change Hello World's parameter</button>
|
|
</div>
|
|
|
|
<script src="src/components/hello-world.js"></script>
|
|
<script src="src/components/hello-world-with-params.js"></script>
|
|
<script src="src/components/cat-img.js"></script>
|
|
<script src="src/components/cat-img-fast.js"></script>
|
|
<script>
|
|
function removeHelloWorld(){
|
|
console.log("Called!");
|
|
|
|
const helloElement = document.getElementsByTagName("hello-world")[0];
|
|
helloElement.parentNode.removeChild(helloElement);
|
|
}
|
|
|
|
function changeHelloWorldParam(){
|
|
const helloParamElement = document.getElementsByTagName("hello-world-with-params")[0];
|
|
document.getElementsByTagName("hello-world-with-params")[0].setAttribute("name", "plop");
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |