/game_js

Primary LanguageHTML

This project sample game by js

Steps:

  1. Create three files:

    index.html
    style.css script.js

  2. In the HTML file, type key emit and do exclamation enter.

  3. In the CSS file, Add a background color to the page: set the color to #c7c7c7.

  4. Change the color of the heading to #3189b3.

  5. Again in the HTML file, we want to link to our stylesheet by type link and enter.

  6. And we also need to link to the JavaScript above the ending body tag. By type script:src and write JS filename "script.js".

  7. Now we will add some JavaScript for Handling Events:

    Add a button to the HTML with the text Jump.
    Create a count variable to store how many times the button is clicked.
    Handle the click event for the button and increment the count variable during each click.
    Give the button an id, so we can refer to it using JavaScript with the documentgetElementByld() function.
    Use the window.onload event to take the reference of our button.
    To handle the click event, use the onclick handler of the button.
    Initialize the count variable to 0 and increment it when the button is clicked, like count += 1.