Skip to content
Programming101
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

HackerRank Day 8: Create a Button 10 Days of javascript solution

YASH PAL, 31 July 2024

In this HackerRank Day 8: Create a Button 10 Days of javascript problem you need to Complete the code in the editor so that it creates a clickable button satisfying the following properties:

  1. The button’s id is btn.
  2. The button’s initial text label is 0. After each click, the button must increment by 1. Recall that the button’s text label is the JS object’s innerHTML property.
  3. The button has the following style properties:
  4. A width of 96px.
  5. A height of 48px.
  6. The font-size attribute is 24px.
HackerRank Day 8: Create a Button 10 Days of javascript solution

HackerRank Day 8: Create a Button 10 Days of javascript problem solution.

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>

10 day of javascript coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes