diff options
author | | 1970-01-01 00:00:00 +0000 |
---|---|---|
committer | | 2025-01-14 03:20:53 +0000 |
commit | 588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6 (patch) | |
tree | f1dbc0e6ff59af610a6043889606a8534ef6b1d4 /10/question.txt | |
parent | rescue 12 (diff) | |
download | html-588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6.tar html-588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6.tar.gz html-588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6.tar.bz2 html-588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6.tar.xz html-588e25e5d0a30c25ca952ccaa1a2f1f1c92a03f6.zip |
rescue
Diffstat (limited to '10/question.txt')
-rw-r--r-- | 10/question.txt | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/10/question.txt b/10/question.txt deleted file mode 100644 index 922968d..0000000 --- a/10/question.txt +++ /dev/null @@ -1,38 +0,0 @@ -Question: -In this exercise, you used an onclick event handler to call -each function. Research the addEventListener() method, and -explain how you would use it instead of an onclick event -handler to call the functions. - -Answer: -To use addEventListener(), I would replace the HTML onclick -attributes with ID attributes. I could then use addEventListener() -in combination with document.getElementById() to run a specific -function depending on which HTML paragraph is clicked. - -HTML: -<main> - <div id="questions"> - <p id="q1">How can I determine if a baby animal - is an orphan?</p> - <p id="q2">How can I tell if an animal has - rabies?</p> - <p id="q3">I found a baby bird that fell from - its nest. Will the parents orphan it if I touch it?</p> - <p id="q4">How can I volunteer?</p> - </div> - <div id="answer"> - <h2>Answer:</h2> - <p></p> - </div> -</main> - -JS: -var q1 = document.getElementById("q1"); -q1.addEventListener("click",ans1); -var q2 = document.getElementById("q2"); -q2.addEventListener("click",ans2); -var q3 = document.getElementById("q3"); -q3.addEventListener("click",ans3); -var q4 = document.getElementById("q4"); -q4.addEventListener("click",ans4); |