diff --git a/01-show-one-element/QUESTIONS.md b/01-show-one-element/QUESTIONS.md index 658796e..c5ddde7 100644 --- a/01-show-one-element/QUESTIONS.md +++ b/01-show-one-element/QUESTIONS.md @@ -6,16 +6,16 @@ > If you click the link to reveal more text and then refresh the page, does the text remain revealed, or is it hidden again? Why? -Your reply here... +Teksts nepaliek atklāts, jo viņš nepaliek uzklikšķināts --- > Remove `window.addEventListener("load", function(){` (and the closing `})`) from **global.js**. Does the link still reveal the text? What is the purpose of this code that you've removed? -Your reply here... +Nē, jo nav pievienota klikšķināšanas notikums. --- > Describe the the `addEventListener` method. (Remember that there is a specific, technical, methodical way to describe methods. Your reply should match that format.) -Your reply here... +Ar to pievieno klikšķināšanas notikumu pogai. diff --git a/01-show-one-element/global.js b/01-show-one-element/global.js index a70fa8c..e69460b 100644 --- a/01-show-one-element/global.js +++ b/01-show-one-element/global.js @@ -1,17 +1,21 @@ window.addEventListener("load", function(){ - // Here is some pseudo-code to help you get started: + // Get the DOM element which will be clicked. + var more_link = document.getElementById("more_text_link"); - // 1. Get the DOM element which will be clicked. + // Add a listener for the 'click' event onto that element. + more_link.addEventListener("click", function(){ - // 2. Add a listener for the 'click' event onto that element. + // The block for the listener should get the DOM + // element containing the text to reveal. + var more_text = document.getElementById("more_text_content"); - // 3. The block for the listener should get the DOM - // element containing the text to reveal. + // Modify that DOM element's style to change it's 'display' + // from a hidden value to a shown value. + more_text.style.display = "inline"; - // 4. Modify that DOM element's style to change it's 'display' - // from a hidden value to a shown value. - - // 5. Also modify the DOM to hide the "More info..." link. + // Also modify the DOM to hide the "More info..." link. + more_link.style.display = "none"; + }); }); \ No newline at end of file diff --git a/02-hide-many-elements/QUESTIONS.md b/02-hide-many-elements/QUESTIONS.md index 2878485..7ff9162 100644 --- a/02-hide-many-elements/QUESTIONS.md +++ b/02-hide-many-elements/QUESTIONS.md @@ -6,10 +6,10 @@ > How did you go about selecting the DOM elements to hide? Describe the "contract" for that function. -Your reply here... +Paslēpšanas pogai liku paslēpt visu ar className 'hide_me' --- > Describe how you were able to hide each element. Were you able to do it as one operation, or did you use a loop of some kind? Describe the "contracts" that were utilized to accomplish your goal. -Your reply here... \ No newline at end of file +Izmantoju for loopu lai apslēptu visus divus ar className 'hide_me' \ No newline at end of file diff --git a/02-hide-many-elements/global.js b/02-hide-many-elements/global.js new file mode 100644 index 0000000..e836c80 --- /dev/null +++ b/02-hide-many-elements/global.js @@ -0,0 +1,14 @@ +window.addEventListener("load", function(){ + + var button = document.getElementById('button'); + + button.addEventListener("click", function() { + + var divs_to_hide = document.getElementsByClassName('hide_me'); + + for (var i = 0; i < divs_to_hide.length; i++) { + divs_to_hide[i].style.display = "none"; + } + }); + + }); \ No newline at end of file diff --git a/02-hide-many-elements/index.html b/02-hide-many-elements/index.html index b1889dd..bf2c6bf 100644 --- a/02-hide-many-elements/index.html +++ b/02-hide-many-elements/index.html @@ -7,17 +7,14 @@