diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c6cbac9 Binary files /dev/null and b/.DS_Store differ diff --git a/exercises/.DS_Store b/exercises/.DS_Store new file mode 100644 index 0000000..42aad34 Binary files /dev/null and b/exercises/.DS_Store differ diff --git a/exercises/part1-selectors-and-events/index.js b/exercises/part1-selectors-and-events/index.js index 25a3025..01a8dcd 100644 --- a/exercises/part1-selectors-and-events/index.js +++ b/exercises/part1-selectors-and-events/index.js @@ -16,30 +16,35 @@ Part 1: Set the variable below equal to the paragraph element representing the first test result. ==================== */ -let firstResult; +let firstResult = document.getElementById("result-1"); +window.firstResult = firstResult; /* ==================== Parts 2: Set the variable below equal to a collection of the paragraph elements representing the 2nd and 3rd results. ==================== */ -let secondAndThirdResults; +let secondAndThirdResults = document.querySelectorAll(".result-2-3"); +window.secondAndThirdResults = secondAndThirdResults; /* ==================== Parts 3: Set the variable below equal to a collection of the paragraph elements representing the all of the results. ==================== */ -let allResults; +let allResults = document.getElementsByClassName("result"); +window.allResults = allResults; /* ==================== Part 4: Add an event listener to the button in problem 4 that changes the button's own text to "I'm Clicked!" ==================== */ -let imClickedButton; +let imClickedButton = document.querySelector("#im-clicked-button"); if (imClickedButton) { - imClickedButton.addEventListener('click', () => {}); + imClickedButton.addEventListener('click', () => { + imClickedButton.innerHTML = "I'm Clicked!" + }); } /* ==================== @@ -56,9 +61,13 @@ HINT: You may need some global state for this problem. let spanContainer = document.querySelector('#span-container'); spanContainer.appendChild(htmlToElement('0')); -let addSpanButton; +let addSpanButton = document.querySelector("#add-span-button"); +let i =0; if (addSpanButton) { - addSpanButton.addEventListener('click', () => {}); + addSpanButton.addEventListener('click', () => { + i++; + spanContainer.appendChild(htmlToElement(''+i+'')); + }); } /* =====================