Is there a way to dynamically add an element with the same id when clicking a button that is linked to JavaScript without any existing JS in place? I initially considered using document.write and then appending a div, but this approach did not work for me. Additionally, I have heard that this practice is not recommended.
This is what I currently have:
HTML:
<!DOCTYPE html/>
<html>
<head>
<title>wat</title>
<meta charset= "UTF-8">
<link rel="stylesheet" type="text/css" href="CssHtmlLapai.css">
<script src="JsLapai.js"></script>
</head>
<body>
<button type="button" onclick="NewDiv()">Click me</button>
<div id="first"></div>
</body>
</html>
CSS:
#first{
width: 100px;
height: 100px;
background-color: red;
}