Giter Site home page Giter Site logo

dom-ajax's Introduction

For homework:

Part 1

Open homework.html in your browser. Notice there are 3 buttons: blue, orange and green. Edit the file .js/homework.js and add the following functionality:

Clicking on the buttons should change the "theme" of the website:

  • When clicking blue it should change: - Jumbotron background color to #588fbd - Donate a bike button background color to #ffa500 - Volunteer button background color to black and text color to white
  • When clicking orange it should change: - Jumbotron background color to #f0ad4e - Donate a bike button background color to #5751fd - Volunteer button background color to #31b0d5 and text color to white
  • When clicking green it should change: - Jumbotron background color to #87ca8a - Donate a bike button background color to black - Volunteer button background color to #8c9c08

You can use either the .className method or setting the styles directly in JavaScript.

Here's an example of how the website should look for the blue button:

Blue button example

Part 2

Just below the buttons, there's a form called Register with us.

Continue working in ./js/homework.js to add the following functionality:

When the submit button is pressed, it should check that all the form fields are valid:

  • The Your name, Email and Describe yourself fields need to be non-empty (Hint: their value length has to be greater than zero)
  • For the Email field also check if it contains the @ character

For all the fields that invalid, it should make their background color red. IF all the fields are valid, when you click Submit it should:

  • Display an alert to thank you for filling out the form
  • Blank out (make empty) all the text fields

Important hint: In your function that handles clicks on the Submit button you will need to call event.preventDefault() to stop the browser from refreshing the page. To read more on how to do this: https://developer.mozilla.org/en/docs/Web/API/Event/preventDefault

dom-ajax's People

Contributors

yjohn avatar rarmatei avatar claudiamatosa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.