diff --git a/01/app.js b/01/app.js index 1c9992e..b57d1f8 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,8 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const elementList = document.querySelector('.comments__item.comments__item--newest'); + +if(elementList !== null) { + const elementWithAttribute = elementList.querySelectorAll('[data-info]'); + console.log("Liczba pasujących elementów:", elementWithAttribute.length); +}; diff --git a/02/app.js b/02/app.js index 1c9992e..cf1ab7d 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,11 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const linkList = document.querySelectorAll('[data-url]'); + +if(linkList !== null) { + linkList.forEach(link => { + const url = link.getAttribute('data-url'); + link.href = url; + console.log("Gotowe url:", link.href); + }); +}; \ No newline at end of file diff --git a/03/app.js b/03/app.js index c299ca3..c08e574 100644 --- a/03/app.js +++ b/03/app.js @@ -11,4 +11,21 @@ const buttonSettings = { color: '#444' }, text: 'Click me!', -} \ No newline at end of file +} + + +const btn = document.createElement('button'); +btn.innerText = buttonSettings.text; + +for(let key in buttonSettings.attr) { + btn[key] = buttonSettings.attr[key] +} + +for(let key in buttonSettings.css) { + btn.style[key] = buttonSettings.css[key]; +} + +console.log(btn); + +const buttonParent = document.querySelector('.parent-for-button'); +buttonParent.appendChild(btn); \ No newline at end of file diff --git a/04/app.js b/04/app.js index e6411e4..476df3a 100644 --- a/04/app.js +++ b/04/app.js @@ -1,3 +1,4 @@ + console.log('DOM'); // struktura do wykorzystania w pętli @@ -5,4 +6,54 @@ const menuItems = [ {text: 'start', url: '/'}, {text: 'galeria', url: '/gallery'}, {text: 'kontakt', url: '/contact'}, -]; \ No newline at end of file +]; + +/* +const ul = document.createElement('ul'); + +const liStart = document.createElement('li'); +ul.appendChild(liStart); + +const startA = document.createElement('a'); +startA.innerText = "Start"; +startA.href = "/"; +liStart.appendChild(startA); + + +const liGallery = document.createElement('li'); +ul.appendChild(liGallery); + +const galleryA = document.createElement('a'); +galleryA.innerText = "Galeria"; +galleryA.href = "/gallery"; +liGallery.appendChild(galleryA); + + +const liContact = document.createElement('li'); +ul.appendChild(liContact); + +const contactA = document.createElement('a'); +contactA.innerText = "Kontakt"; +contactA.href = "/contact"; +liContact.appendChild(contactA); +console.log(ul); + +const nav = document.querySelector('nav'); +nav.appendChild(ul); +*/ + + +const ul = document.createElement('ul'); + +for(let menu of menuItems) { + const li = document.createElement('li'); + const a = document.createElement('a'); + a.innerText = menu.text; + a.href = menu.url; + li.appendChild(a); + ul.appendChild(li); +} + +const nav = document.querySelector('nav'); +nav.appendChild(ul); +console.log(ul); diff --git a/05/app.js b/05/app.js index 39abe5d..f09dc4f 100644 --- a/05/app.js +++ b/05/app.js @@ -1,3 +1,30 @@ console.log('DOM'); const curr = document.querySelector('.js-curr'); + +const newBtn = document.createElement('button'); +newBtn.innerText = 'Usuń z koszyka'; +curr.after(newBtn); + +const parent = curr.parentElement; + +for(let child of parent.children) { + if( child !== curr) { + child.classList.add('siblings'); + } +} + +const nextArticle = parent.nextElementSibling; +nextArticle.setAttribute('title', 'nextElementSibling'); + +const lastArticle = nextArticle.nextElementSibling; +const nextP = document.createElement('p'); +lastArticle.insertBefore(nextP, lastArticle.lastElementChild); + + +const cloneArticle = parent.cloneNode(true); +const section = parent.parentElement; +section.insertBefore(cloneArticle, section.firstElementChild); + +console.log(section); +