Hacker News new | past | comments | ask | show | jobs | submit login

sweet! but alas, I'm looking through the examples and one line of simple+clear JQuery is a often a dozen tricky lines of pure CSS.



I usually take it as suggestive code that you don’t have to use verbatim.

For example, You might not need jQuery offers the following suggestions:

  // toggle visibility
  function toggle(el) {
    if (el.style.display == 'none') {
      el.style.display = '';
    } else {
      el.style.display = 'none';
    }
  }

  // remove multiple elements
  for (const el of document.querySelectorAll(selector)) {
    el.remove();
  }
While the following would be more concise:

  // toggle visibility
  function toggle(el) {
    el.style.display = el.style.display === 'none' ? '' : 'none;
  }

  // remove multiple elements
  document.querySelectorAll(selector).forEach(el => el.remove());




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: