This is an application where user can create a box of width, height and color according to their need. User enters width, height and color of box and after that according to user input box will display on the screen.User can create multiple boxes on the screen.
There is also remove button to delete all the boxes.
HTML Code
<button onclick=createBox()> Click to create box</button>
<button onclick=remove()>To remove All boxes</button>
<div id="box">
</div>
<script src="script.js"></script>
Javascript Code
var a = 0;
function createBox() {
var width = prompt("Enter width of box")
var height = prompt("Enter height of box")
var color = prompt("Enter color of box")
var display = document.getElementById('box');
display.style.display = "flex";
var newNode = document.createElement('div');
newNode.className = `box${a + 1}`;
newNode.style.width = `${width}px`
newNode.style.height = `${height}px`
newNode.style.backgroundColor = `${color}`;
newNode.style.display = "block"
document.getElementById('box').appendChild(newNode);
}
function remove() {
window.location.reload()
}
For assignment help of this sample assignment mail us on contact@codersarts.com
Also, If you are looking for any kind of coding help in programming languages,web developing Contact us for instant solution
Comments