0

I have a basic search that looks through divs, displays those with the matching text and hides the rest, but how can I add hidden "meta" tags that would be included in the search but not displayed?

Example:

Window (has hidden "meta" tag 'Glass') Door (has hidden "meta" tag 'Wood')

So when I type "Glass" in the search bar it only displays Window as a result (Glass element is still hidden).

  • 2
    You can use [`data-*` attributes](https://stackoverflow.com/q/30417852/4642212) or even [`WeakMap`s](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) to store meta information on HTML elements. Do you have some example code? – Sebastian Simon Apr 04 '21 at 22:18
  • I've just posted an edit. I've figured something out that works just as well, but thank you, I'll check out your suggestion as well. – Mezmerizer 9 Apr 04 '21 at 22:19

1 Answers1

0

EDIT: Nevermind, I'm sleep deprived and actually thought of the solution. I've just placed a hidden div behind the main div itself and that was basically it for the most part.