Add a button a script can find by id.
Acceptance criteria
- 1.Add a button a script can find by id.
HTML Tutorial · HTML References
These 10 tasks go with the Event Attributes chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “HTML event attributes allow you to add interactivity to your webpage. They define how elements respond when certain events occur — such as when a user clicks a button, hovers over an image, submits a form, presses a key, or moves the mouse. In short, event attributes connect HTML with JavaScript to make webpages dynamic and interactive.” .
1.Give the button an idexercise · easy · 10 min
Add a button a script can find by id.
Passes when: Add a button a script can find by id.
2.Two identified controlsexercise · easy · 10 min · practice plan
Add two buttons, each with its own id.
Passes when: Add two buttons, each with its own id.
3.A described controlexercise · easy · 10 min · practice plan
Give the button an accessible label.
Passes when: Give the button an accessible label.
4.A form with a submitexercise · easy · 10 min · practice plan
Add a form whose button submits it.
Passes when: Add a form whose button submits it.
5.A script-ready pageexercise · medium · 10 min · practice plan
Add an identified button and a deferred script.
Passes when: Add an identified button and a deferred script.
6.Fix the inline handlerbug fix · easy · 8 min
Behaviour belongs in a script, not an onclick attribute.
Passes when: Behaviour belongs in a script, not an onclick attribute.
7.Fix the second control with no idbug fix · easy · 8 min · practice plan
A script cannot find the cancel button.
Passes when: A script cannot find the cancel button.
8.Fix the icon button with no namebug fix · easy · 8 min · practice plan
A symbol alone tells a screen reader nothing.
Passes when: A symbol alone tells a screen reader nothing.
9.Fix the form submitted by an inline handlerbug fix · easy · 8 min · practice plan
A submit button submits the form on its own.
Passes when: A submit button submits the form on its own.
10.Fix the page with no scriptbug fix · easy · 8 min · practice plan
The identified button has nothing wired to it.
Passes when: The identified button has nothing wired to it.
Between them these tasks cover Inline handlers, Why to avoid them and Buttons and ids.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.