-
Notifications
You must be signed in to change notification settings - Fork 172
Done #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Done #149
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,11 @@ | ||
| console.log('DOM'); | ||
|
|
||
| const liElement = document.querySelector('.comments__item.comments__item--newest'); | ||
| const dataInfoList = liElement.querySelectorAll('[data-info]'); | ||
|
|
||
| if(liElement && dataInfoList) { | ||
| console.log(`Znaleziono ${dataInfoList.length} poniższe elementy z atrybutem data-info :`); | ||
|
|
||
| dataInfoList.forEach(function(element) { | ||
| console.log(element) | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,10 @@ | ||
| console.log('DOM'); | ||
| const linkList = document.querySelectorAll('[data-url') | ||
|
|
||
| linkList.forEach(function(link) { | ||
| const url = link.getAttribute('data-url'); | ||
|
|
||
| if(url) { | ||
| link.setAttribute('href', url) | ||
| } | ||
| }); | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,4 +11,20 @@ const buttonSettings = { | |
| color: '#444' | ||
| }, | ||
| text: 'Click me!', | ||
| } | ||
|
|
||
| const button = document.createElement('button'); | ||
|
|
||
| for (const attr in buttonSettings.attr) { | ||
| button[attr] = buttonSettings.attr[attr]; | ||
| } | ||
| for (const style in buttonSettings.css) { | ||
| button.style[style] = buttonSettings.css[style]; | ||
| } | ||
|
|
||
| button.textContent = buttonSettings.text; | ||
|
|
||
| const parentButton = document.querySelector('.parent-for-button'); | ||
| if (parentButton) { | ||
| parentButton.appendChild(button); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,24 @@ | ||
| console.log('DOM'); | ||
|
|
||
| // struktura do wykorzystania w pętli | ||
| const menuItems = [ | ||
| {text: 'start', url: '/'}, | ||
| {text: 'galeria', url: '/gallery'}, | ||
| {text: 'kontakt', url: '/contact'}, | ||
| ]; | ||
| ]; | ||
|
|
||
| const nav = document.querySelector('nav'); | ||
| const ul = document.createElement('ul'); | ||
|
|
||
|
|
||
|
|
||
| menuItems.forEach(function(item) { | ||
| const li = document.createElement('li'); | ||
| const a = document.createElement('a'); | ||
| a.href = item.url; | ||
| a.textContent = item.text; | ||
|
|
||
| li.appendChild(a); | ||
| ul.appendChild(li); | ||
| }); | ||
|
|
||
| nav.appendChild(ul); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,45 @@ | ||
| console.log('DOM'); | ||
|
|
||
| const curr = document.querySelector('.js-curr'); | ||
|
|
||
| // | ||
| const newButton = document.createElement('button'); | ||
| newButton.classList.add('article__btn'); | ||
| newButton.textContent = 'usuń z koszyka' | ||
|
|
||
| curr.parentElement.insertBefore(newButton, curr.nextElementSibling); | ||
|
|
||
|
|
||
| // | ||
| let sibling = curr.parentElement.firstElementChild; | ||
| while (sibling) { | ||
| if (sibling !== curr) { | ||
| sibling.classList.add('siblings'); | ||
| } | ||
| sibling = sibling.nextElementSibling; | ||
| } | ||
|
|
||
|
|
||
| // | ||
| const nextArticle = curr.closest('.article').nextElementSibling; | ||
| if(nextArticle && nextArticle.classList.contains('article')) { | ||
| nextArticle.setAttribute('title', 'nextElementSibling'); | ||
| } | ||
|
|
||
|
|
||
| // | ||
| const lastArticle = document.querySelector('.articles__item:last-child'); | ||
| const paragraph = document.createElement('p'); | ||
| paragraph.textContent = 'Dodskowy paragraf.'; | ||
| const button = lastArticle.querySelector('.article__btn'); | ||
| lastArticle.insertBefore(paragraph, button); | ||
|
|
||
| // | ||
| const newArticle = document.createElement('article'); | ||
| newArticle.classList.add('articles__item', 'article'); | ||
| const articlesSection = document.querySelector('.articles'); | ||
| articlesSection.insertBefore(newArticle, articlesSection.firstElementChild); | ||
|
|
||
| newArticle.innerHTML = ` | ||
| <h1 class="article__title">JS- Nowy Artykuł</h1> | ||
| <p class="article__description">Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur quo quibusdam, nemo neque consequuntur pariatur totam? Facere quaerat molestias hic.</p> | ||
| <button class="article__btn">Kupuję!</button> | ||
| `; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tutaj mamy drobny błąd logiczny - sprawdzasz czy element został wyszukany później niż go wykorzystujesz.
Powinno być:
Nie trzeba sprawdzać
dataInfoListbo to tablica elementów więc nieważne czy jest ich 0 czy więcej to błędu nie będzie.