Files
web-components-workshop-dep…/index.html
2017-12-08 10:46:32 +01:00

41 lines
1.4 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>
<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>
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>