<!DOCTYPE html>
<html>
<body>
<span>Total clicks :0</span>
<button id="btn">Click me</button>
</body>
<script>
let counter = 0;
const button = document.getElementById("btn");
const span = document.querySelector("span")
function handleClick() {
counter = counter +1;
span.innerText = `Total clicks :${counter}`
}
button.addEventListener("click",handleClick )
</script>
</html>
<!DOCTYPE html>
<html>
<body>
<div id="root"></div>
</body>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script>
const root = document.getElementById("root")
const span = React.createElement(
"span",
{id: "sexy-span"},
"Hello I'm a SPAN"
);
ReactDOM.render(span, root )
</script>
</html>
<!DOCTYPE html>
<html>
<body>
<div id="root"></div>
</body>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
<script>
const root = document.getElementById("root")
const h3 = React.createElement("h3",{
onMouseEnter : () => console.log("mouse entered"),
},"Hello I'm a SPAN" );
const btn = React.createElement(
"button",
{onClick: () => console.log("im clicked"),},
"Click Me");
const container = React.createElement("div", null, [h3, btn]);
ReactDOM.render(container, root )
</script>
</html>
조금 늦더라도 이해를 반드시 하고 가자.
나중에 모른다고 처음으로 돌아오면 그게 더 큰일이다.