Jump to content

Marjo

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Marjo

  1. *facepalm* Yep, no, you're absolutely right, I accidentally messed up part of the CSS when I tested this earlier 🥴 Works like a charm now, thanks a ton!
  2. Thank you both for your input! @Ingolme I tried out your code, but I think I'm overlooking something because it doesn't seem to actually filter anything. It might be something obvious, as I'm very new to JS. Is there still something I'm supposed to add for this code to work (apart from CSS for styling)?
  3. Hi all! I've been looking at this code snippet that lets you filter div elements based on their class name: https://www.w3schools.com/howto/howto_js_filter_elements.asp I'm wondering how you would go about applying multiple filters to some elements, similar to turning filters on and off, or using boolean operators like AND, OR or NOT. For example (using the dataset used in the link above): assume you want to filter out all the elements that are animals AND whose name is 3 letters long ("cat", "dog" and "cow"). I know it's a silly example, it's just to get my point across. 😅 If you'd make a separate class name for the length of the name, as I understand it you'd still only be able to filter for elements that are animals ("mustang", "cat", "dog", "kiwi" and "cow") OR that have 3 letters ("red", "blue", "cat", "dog" and "cow") - you can't combine both filters. Is there an elegant way to accomplish this that's similar to the code used in the site's example? Or would you have to change your entire approach? (Or is this not possible at all and would you be stuck having to make a separate class name for each and every combination? 😨 That... doesn't sound very practical.) Thanks in advance!
×
×
  • Create New...