Javascript Create a class that implements a small white rect
Javascript
Create a class that implements a small white rectangular button which occupies 1% of the width and 1% of the height of the parent element, and it also has a method to toggle the button. The toggle function when it is called it will change the color of the button to black. If it is called again, it will turn it white and so on.
Now, your main program should create 10000 (100px by 100px div) objects of this class, and they should cover all your screen area, each of them occupying 1%x1% area of your screen.
With the program, you can paint a pixel drawing by clicking on various buttons on the screen, because each element is a toggle button.
Solution
<!DOCTYPE html>
<html>
<head>
<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js\"></script>
<script>
$(document).ready(function(){
$(\"button\").click(function(){
$(\"div\").toggle();
});
});
</script>
</head>
<body>
<div style=\"width:90px;height:70px;border:1px solid #000;\"></div>
<button>Toggle</button>
</body>
</html>
