In this HackerRank Day 8: Create a Button 10 days of javascript problem solution we need to create buttons in the javascript.

HackerRank Day 8: Create a Button problem solution

Problem solution in JavaScript programming.

CSS file.


.btnClass {

    width: 96px;

    height: 48px;

    font-size: 24px;

}


JavaScript file

var btn = document.createElement("Button");


btn.innerHTML = "0";

btn.id = "btn";

btn.className = "btnClass";


document.body.appendChild(btn);


btn.onclick = function() {

    btn.innerHTML+=2;

}

HTML file

<!-- Enter your HTML code here -->

<!DOCTYPE html>

<html>

    <head>

        <meta charset="utf-8">

        <title>Button</title>

    </head>

    <body>

    </body>

</html>