-
Notifications
You must be signed in to change notification settings - Fork 172
done #155
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 #155
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,10 @@ | ||
| console.log('DOM'); | ||
| console.log('DOM'); | ||
|
|
||
| const UlElement = document.querySelector('ul'); | ||
| if (UlElement) { | ||
| const classElement = UlElement.querySelector( | ||
| '.comments__item.comments__item--newest' | ||
| ); | ||
| const dataInfo = classElement.querySelectorAll('[data-info]'); | ||
| console.log(dataInfo.length); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| console.log('DOM'); | ||
| console.log('DOM'); | ||
|
|
||
| const linksEl = document.querySelectorAll('[data-url]'); | ||
| linksEl.forEach((link) => { | ||
| const url = link.dataset.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 |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| console.log('DOM'); | ||
|
|
||
| const buttonSettings = { | ||
| attr: { | ||
| className: 'btn', | ||
| title: 'super button' | ||
| }, | ||
| css: { | ||
| border: '1px solid #336699', | ||
| padding: '5px 20px', | ||
| color: '#444' | ||
| }, | ||
| text: 'Click me!', | ||
| } | ||
| attr: { | ||
| className: 'btn', | ||
| title: 'super button', | ||
| }, | ||
| css: { | ||
| border: '1px solid #336699', | ||
| padding: '5px 20px', | ||
| color: '#444', | ||
| }, | ||
| text: 'Click me!', | ||
| }; | ||
|
|
||
| const button = document.createElement('button'); | ||
| for (const key in buttonSettings.attr) { | ||
| button[key] = buttonSettings.attr[key]; | ||
| } | ||
| for (const styleKey in buttonSettings.css) { | ||
| button.style[styleKey] = buttonSettings.css[styleKey]; | ||
| } | ||
| button.innerText = buttonSettings.text; | ||
|
|
||
| const parentElement = document.querySelector('.parent-for-button'); | ||
| if (parentElement) { | ||
| parentElement.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 |
|---|---|---|
|
|
@@ -2,7 +2,54 @@ console.log('DOM'); | |
|
|
||
| // struktura do wykorzystania w pętli | ||
| const menuItems = [ | ||
| {text: 'start', url: '/'}, | ||
| {text: 'galeria', url: '/gallery'}, | ||
| {text: 'kontakt', url: '/contact'}, | ||
| ]; | ||
| { text: 'start', url: '/' }, | ||
| { text: 'galeria', url: '/gallery' }, | ||
| { text: 'kontakt', url: '/contact' }, | ||
| ]; | ||
|
|
||
| // z użyciem pętli | ||
| const navElement = document.querySelector('nav'); | ||
| const ulElement = document.createElement('ul'); | ||
|
|
||
| menuItems.forEach((item) => { | ||
|
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. Jak widać zdecydowanie wygodniej i lepiej używać pętli :) |
||
| const li = document.createElement('li'); | ||
| const a = document.createElement('a'); | ||
|
|
||
| a.setAttribute('href', item.url); | ||
| a.innerText = item.text; | ||
|
|
||
| li.appendChild(a); | ||
| ulElement.appendChild(li); | ||
| }); | ||
|
|
||
| navElement.appendChild(ulElement); | ||
|
|
||
| //bez pętli | ||
|
|
||
| const ulElement = document.createElement('ul'); | ||
| const li1 = document.createElement('li'); | ||
| const a1 = document.createElement('a'); | ||
| const li2 = document.createElement('li'); | ||
| const a2 = document.createElement('a'); | ||
| const li3 = document.createElement('li'); | ||
| const a3 = document.createElement('a'); | ||
| const navElement = document.querySelector('nav'); | ||
| a1.setAttribute('href', '/'); | ||
| a1.innerText = 'start'; | ||
| li1.appendChild(a1); | ||
| ulElement.appendChild(li1); | ||
|
|
||
|
|
||
| a2.setAttribute('href', '/gallery'); | ||
| a2.innerText = 'galeria'; | ||
| li2.appendChild(a2); | ||
| ulElement.appendChild(li2); | ||
|
|
||
| a3.setAttribute('href', '/contact'); | ||
| a3.innerText = 'kontakt'; | ||
| li3.appendChild(a3); | ||
| ulElement.appendChild(li3); | ||
|
|
||
|
|
||
| navElement.appendChild(ulElement); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,52 @@ | ||
| console.log('DOM'); | ||
|
|
||
| const curr = document.querySelector('.js-curr'); | ||
| const button = document.createElement('button'); | ||
| button.innerText = 'usuń z koszyka'; | ||
| curr.parentElement.appendChild(button); | ||
|
|
||
| const parent = curr.parentElement; | ||
| const children = parent.children; | ||
|
|
||
| for (let i = 0; i < children.length; i++) { | ||
| if (children[i] !== curr) { | ||
| children[i].classList.add('siblings'); | ||
| } | ||
| } | ||
|
|
||
| const nextArticle = parent.nextElementSibling; | ||
| if (nextArticle && nextArticle.classList.contains('article')) { | ||
| nextArticle.setAttribute('title', 'nextElementSibling'); | ||
| } | ||
|
|
||
| const articles = document.querySelectorAll('.article'); | ||
| const lastArticle = articles[articles.length - 1]; | ||
| const lastButton = lastArticle.querySelector('button'); | ||
| const newParagraph = document.createElement('p'); | ||
| newParagraph.innerText = 'Nowy paragraf przed przyciskiem'; | ||
|
|
||
| lastArticle.insertBefore(newParagraph, lastButton); | ||
|
|
||
| const newArticle = document.createElement('article'); | ||
| newArticle.classList.add('articles__item', 'article'); | ||
|
|
||
| const newTitle = document.createElement('h1'); | ||
| newTitle.classList.add('article__title'); | ||
| newTitle.innerText = 'Nowy artykuł'; | ||
|
|
||
| const newDescription = document.createElement('p'); | ||
| newDescription.classList.add('article__description'); | ||
| newDescription.innerText = 'Nowy opis'; | ||
|
|
||
| const newButton = document.createElement('button'); | ||
| newButton.classList.add('article__btn'); | ||
| newButton.innerText = 'Nowy przycisk'; | ||
|
|
||
| newArticle.appendChild(newTitle); | ||
| newArticle.appendChild(newDescription); | ||
| newArticle.appendChild(newButton); | ||
|
|
||
|
|
||
| const articlesContainer = document.querySelector('.articles'); | ||
|
|
||
| articlesContainer.insertBefore(newArticle, articlesContainer.firstChild); | ||
|
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.
👍