Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Javascript Create a class that implements a small white rectangular button which

ID: 3933769 • Letter: J

Question

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.

Explanation / Answer

<!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></div>
<button>Toggle</button>

</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote