In JavaScript, the target property is not directly associated with a forEach() loop itself. However, when you’re using forEach() to iterate over a collection of DOM elements (like those obtained from document.querySelectorAll()), you might encounter the target property if you’re working with event listeners inside the loop.
Here’s an example:
document.querySelectorAll('.my-button').forEach(button => {
button.addEventListener('click', (event) => {
console.log(event.target); // This will log the button that was clicked
});
});
In this case, event.target refers to the element that triggered the event (e.g., the button that was clicked). So, while target isn’t specific to the forEach() loop, you may use it inside the loop when handling events on elements.
The News page has been added back to the website. Some news sources were removed as they often produced RSS errors or the headlines were simply too bombastic or misleading by my standards.
On the tech side of it, I did have to add some JavaScript to the native WordPress RSS widgets, so that I links opened in a new tab, etc., below is the code snippet:
<script> // Open link in new tab let link = document.querySelectorAll('.wp-block-rss__item a') link.forEach((e) => {e.setAttribute("target", "_blank")}) // Add inline style to the <ul> let news_list = document.querySelectorAll("ul.wp-block-rss") news_list.forEach((e) => {e.setAttribute("style", "list-style-type:none; margin: 1rem auto;");}) // Make the title inline let wp_block_rss_item_title = document.querySelectorAll('div.wp-block-rss__item-title') wp_block_rss_item_title.forEach((e) => {e.setAttribute("style", "display:inline-block!important;");}) // Style the publish date let wp_block_rss_item_publish_date = document.querySelectorAll('.wp-block-rss__item-publish-date') wp_block_rss_item_publish_date.forEach((e) => {e.setAttribute("style", "display:inline-block!important; font-weight:bold; margin:0 8px;")})</script>