Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion 01/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
console.log('DOM');
console.log('DOM');

const commentsItem = document.querySelector('.comments__item ', '.comments__item--newest')
const DataInfoElements = commentsItem.querySelectorAll('[data-info]')
console.log(`znaleziono ${DataInfoElements.length} elementów wewnątrz elementu z tagiem ${commentsItem.nodeName}`)
8 changes: 7 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
console.log('DOM');
console.log('DOM');
const allLinks = document.querySelectorAll("[data-url]")
console.log(allLinks)
allLinks.forEach(link => {
const value = link.dataset.url
link.setAttribute('href', value)
})
31 changes: 30 additions & 1 deletion 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,33 @@ const buttonSettings = {
color: '#444'
},
text: 'Click me!',
}
}

const newBtn = document.createElement('button')
for(const key in buttonSettings) {
const value = buttonSettings[key]
if(typeof value === 'object' && value !== null ) {
if(key == 'attr') {
for(const property in value) {
newBtn.setAttribute(property, value[property])
console.log(`${property}: ${value[property]}`)

}
}
if(key == 'css') {
for(const property in value) {
newBtn.style[property] = value[property]
console.log(`${property}: ${value[property]}`)
}
}

} else {
console.log(`${key}: ${value}`)
newBtn.innerText = value
}
}

const parent = document.querySelector('.parent-for-button')
console.log(parent)
parent.appendChild(newBtn)

31 changes: 27 additions & 4 deletions 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@ 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'
},
];

const ulList = document.createElement('ul')
menuItems.forEach(item => {
newLi = document.createElement('li')
newA = document.createElement('a')
newA.innerText = item.text
newA.setAttribute('href',item.url)

newLi.appendChild(newA)
ulList.appendChild(newLi)

})
const nav = document.querySelector('nav')
nav.appendChild(ulList)
31 changes: 31 additions & 0 deletions 05/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
console.log('DOM');

const curr = document.querySelector('.js-curr');
const parent = curr.parentElement
const newBtn = document.createElement('button')
newBtn.innerText = "Usuń z koszyka"
parent.appendChild(newBtn)

const children = Array.from(parent.children)

const sliblings = children.filter(child => child !== curr)

console.log(sliblings)
console.log(sliblings)
for(let i = 0; i < sliblings.length; i++){
sliblings[i].classList.toggle('sliblings')
}

parent.nextElementSibling.setAttribute('title','nextElementSlibling')

const lastArticle = parent.parentElement.lastElementChild
const pElement = document.createElement('p')
pElement.innerText = 'new paragraph'
const articlebutton = lastArticle.querySelector('button')
lastArticle.insertBefore(pElement,articlebutton)

const newArticle = document.createElement('article')
newArticle.classList.add('articles__item', 'article')
newArticle.innerHTML =
`<h1 class="article__title">JS - Elementy DOM2</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 js-curr">Kupuję!</button>`

parent.parentElement.insertBefore(newArticle,parent)