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 @@
- I have the class "show_me", and will stick around even after you click the button at the bottom. + Šim div ir class="show_me", tas nepazudīs
- I have the class "hide_me"; I should disappear when you click the button at the bottom. -
- -
- I'm also part of the "hide_me" class, and should also disappear. + Šim div ir class="hide_me", tas pazudīs
+ \ No newline at end of file diff --git a/03-show-many-elements/QUESTIONS.md b/03-show-many-elements/QUESTIONS.md index de6f46c..f4f9986 100644 --- a/03-show-many-elements/QUESTIONS.md +++ b/03-show-many-elements/QUESTIONS.md @@ -6,4 +6,4 @@ > How did you go about hiding elements initially? -Your reply here... \ No newline at end of file +Paslēptajiem elementiem bija style="display: none" atribūts, kas tos atklājot pārmainījās uz style="display: block. " \ No newline at end of file diff --git a/03-show-many-elements/global.js b/03-show-many-elements/global.js new file mode 100644 index 0000000..9b0abba --- /dev/null +++ b/03-show-many-elements/global.js @@ -0,0 +1,14 @@ +window.addEventListener("load", function(){ + + var button = document.getElementById('button'); + + button.addEventListener("click", function() { + + var divs_to_show = document.getElementsByClassName('show_me'); + + for (var i = 0; i < divs_to_show.length; i++) { + divs_to_show[i].style.display = "block"; + } + }); + + }); \ No newline at end of file diff --git a/03-show-many-elements/index.html b/03-show-many-elements/index.html new file mode 100644 index 0000000..aab0cbb --- /dev/null +++ b/03-show-many-elements/index.html @@ -0,0 +1,19 @@ + + + + 3. uzdevums + + + + + + + + + + + \ No newline at end of file diff --git a/04-toggle-many-elements/global.js b/04-toggle-many-elements/global.js index 1df9d74..bf1c7e2 100644 --- a/04-toggle-many-elements/global.js +++ b/04-toggle-many-elements/global.js @@ -1 +1,20 @@ -// Your JavaScript goes here. \ No newline at end of file +// Your JavaScript goes here. +window.addEventListener("load", function(){ + + var button = document.getElementById('button'); + + button.addEventListener("click", function() { + + var divs_to_toggle = document.getElementsByClassName('toggle_me'); + + for (var i = 0; i < divs_to_toggle.length; i++) { + if (divs_to_toggle[i].style.display === "none") { + divs_to_toggle[i].style.display = "block"; + } + else { + divs_to_toggle[i].style.display = "none"; + } + } + }); + + }); \ No newline at end of file diff --git a/05-toggle-elements-of-dom-path/QUESTIONS.md b/05-toggle-elements-of-dom-path/QUESTIONS.md index 2964861..deb19c5 100644 --- a/05-toggle-elements-of-dom-path/QUESTIONS.md +++ b/05-toggle-elements-of-dom-path/QUESTIONS.md @@ -6,4 +6,4 @@ > Describe the contract you used for finding the movies to toggle in the DOM. How is this function different from other functions that find elements in the DOM? -Your reply here... \ No newline at end of file +Tā komanda paņem no abiem sarakstiem vajadzīgo sarakstu, bet iepriekšējās komandas paņem no visa, to kas atzīmēts ar kādu klasi. \ No newline at end of file diff --git a/05-toggle-elements-of-dom-path/global.js b/05-toggle-elements-of-dom-path/global.js index 1df9d74..c4ea024 100644 --- a/05-toggle-elements-of-dom-path/global.js +++ b/05-toggle-elements-of-dom-path/global.js @@ -1 +1,21 @@ -// Your JavaScript goes here. \ No newline at end of file +// Your JavaScript goes here. +window.addEventListener("load", function(){ + + var button = document.getElementById('toggle_button'); + + button.addEventListener("click", function() { + + var movieList = document.querySelectorAll("ul.second_five li"); + + for (var i = 0; i < movieList.length; i++) { + if (movieList[i].style.display === "list-item") { + movieList[i].style.display = "none"; + } + else { + movieList[i].style.display = "list-item"; + } + } + + }); + + }); \ No newline at end of file diff --git a/06-detecting-typed-input/global.js b/06-detecting-typed-input/global.js index 1df9d74..5ec9373 100644 --- a/06-detecting-typed-input/global.js +++ b/06-detecting-typed-input/global.js @@ -1 +1,14 @@ -// Your JavaScript goes here. \ No newline at end of file +// Your JavaScript goes here. +window.addEventListener("load", function(){ + + var name_field = document.getElementById("full_name"); + + name_field.addEventListener("keyup", function() { + + var greeting_div = document.getElementById("greeting"); + + greeting_div.innerHTML = ("Hello there, " + name_field.value + "!"); + + }); + + }); \ No newline at end of file diff --git a/07-automatic-tabbing-fields/QUESTIONS.md b/07-automatic-tabbing-fields/QUESTIONS.md index 4e920ca..782abaf 100644 --- a/07-automatic-tabbing-fields/QUESTIONS.md +++ b/07-automatic-tabbing-fields/QUESTIONS.md @@ -6,4 +6,3 @@ > What are some refactoring techniques you might apply to the provided solution? -Your reply here... \ No newline at end of file diff --git a/07-automatic-tabbing-fields/global.js b/07-automatic-tabbing-fields/global.js index 1df9d74..2261342 100644 --- a/07-automatic-tabbing-fields/global.js +++ b/07-automatic-tabbing-fields/global.js @@ -1 +1,26 @@ -// Your JavaScript goes here. \ No newline at end of file +// Your JavaScript goes here. +window.addEventListener("load", function(){ + + var area_code = document.getElementById('first'); + var middle_numbers = document.getElementById('second'); + var end_numbers = document.getElementById('third'); + + area_code.addEventListener("keyup", function() { + typed_characters = area_code.value.length; + max_characters = parseInt(area_code.getAttribute("maxlength")); + + if (typed_characters === max_characters) { + middle_numbers.focus(); + } + }); + + middle_numbers.addEventListener("keyup", function() { + typed_characters = middle_numbers.value.length; + max_characters = parseInt(middle_numbers.getAttribute("maxlength")); + + if (typed_characters === max_characters) { + end_numbers.focus(); + } + }); + + }); \ No newline at end of file