2022.06.13

JS selector

HTML

<section id="feedsection">
  <ul id="feeds">
    <template id="settings-feed-item">
      <li>
        <a id="remove">x&emsp;</a><span id="feedurl"></span><a></a>
      </li>
    </template>
  </ul>
</section>

JavaScript

// RENDER SETTINGS MENU
function renderSettings() {
  keywords.value = state.keywords;
  newsFeeds.innerHTML = '';
  state.feeds.forEach(f => {
    const el = document.importNode(feedItem.content, true).querySelector('li');
    el.querySelector('span').innerText = simplifyLink(f.url);
    // ...
    // Click Remove button
    el.querySelectorAll('a')[0].onclick = () => {
      // DO SOMETHING TO CLICKED FEED
    };
		// ...
  });
}