diff --git a/01/app.js b/01/app.js index 1c9992e..448fdd1 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,9 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const commentsItem = document.querySelector( + '.comments__item.comments__item--newest' +); + +const dataInfo = commentsItem.querySelectorAll('[data-info]'); + +console.log(dataInfo.length); diff --git a/02/app.js b/02/app.js index 1c9992e..a1eab56 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,8 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); + +const links = document.querySelectorAll('a[data-url]'); + +links.forEach((element) => { + const dataUrl = element.getAttribute('data-url'); + element.setAttribute('href', dataUrl); +}); diff --git a/03/app.js b/03/app.js index c299ca3..2011b0b 100644 --- a/03/app.js +++ b/03/app.js @@ -1,14 +1,30 @@ console.log('DOM'); const buttonSettings = { - attr: { - className: 'btn', - title: 'super button' - }, - css: { - border: '1px solid #336699', - padding: '5px 20px', - color: '#444' - }, - text: 'Click me!', -} \ No newline at end of file + attr: { + className: 'btn', + title: 'super button', + }, + css: { + border: '1px solid #336699', + padding: '5px 20px', + color: '#444', + }, + text: 'Click me!', +}; + +const button = document.createElement('button'); +const buttonParent = document.querySelector('.parent-for-button'); + +for (const prop in buttonSettings.attr) { + button.setAttribute(prop, buttonSettings.attr[prop]); +} + +for (const prop in buttonSettings.css) { + console.log(buttonSettings.css[prop]); + button.style[prop] = buttonSettings.css[prop]; +} + +button.innerText = buttonSettings.text; + +buttonParent.appendChild(button); diff --git a/04/app.js b/04/app.js index e6411e4..3fd62a2 100644 --- a/04/app.js +++ b/04/app.js @@ -2,7 +2,27 @@ console.log('DOM'); // struktura do wykorzystania w pętli const menuItems = [ - {text: 'start', url: '/'}, - {text: 'galeria', url: '/gallery'}, - {text: 'kontakt', url: '/contact'}, -]; \ No newline at end of file + { text: 'start', url: '/' }, + { text: 'galeria', url: '/gallery' }, + { text: 'kontakt', url: '/contact' }, +]; + +const menu = document.createElement('ul'); + +//bez foreach +menu.innerHTML = ` +