Files
JavaScript-from-Beginner-to…/Chapter 09/Code Samples/ch9-attributes.html
T
brightboost 67a8d8a7a0 reorganizing
2021-12-02 21:21:10 +01:00

26 lines
606 B
HTML
Executable File

<html>
<body>
<script>
function changeAttr(){
let el = document.getElementById("shape");
el.setAttribute("style", "background-color:red;border:1px solid black");
el.setAttribute("id", "new");
el.setAttribute("class", "circle");
}
</script>
<style>
div {
height: 100px;
width: 100px;
background-color: yellow;
}
.circle {
border-radius: 50%;
}
</style>
<div id="shape" class="square"></div>
<button onclick="changeAttr()">Change attributes...</button>
</body>
</html>