diff --git a/01/app.js b/01/app.js index 1c9992e..41bf446 100644 --- a/01/app.js +++ b/01/app.js @@ -1 +1,7 @@ -console.log('DOM'); \ No newline at end of file +console.log('DOM'); +const comments = document.querySelector('.comments__item.comments__item--newest'); + +if (comments) { + const elementsWithDataInfo = comments.querySelectorAll('[data-info]'); + console.log('The number of elements that have the attribute data-info:', elementsWithDataInfo.length); +} \ No newline at end of file diff --git a/02/app.js b/02/app.js index 1c9992e..105c609 100644 --- a/02/app.js +++ b/02/app.js @@ -1 +1,16 @@ -console.log('DOM'); \ No newline at end of file +document.addEventListener('DOMContentLoaded', function () { + const links = document.querySelectorAll('a[data-url]'); + + links.forEach(link => { + const url = link.getAttribute('data-url'); + + if (url !== 'null') { + link.setAttribute('href', url); + } else { + link.style.color = 'grey'; + link.addEventListener('click', function (event) { + event.preventDefault(); + }); + } + }); +});