The question is quite simple, I'm wondering how I can create HTMLCollection. Let's say I have some divs inside var. I'm wondering how I can create HTML collection from that variable. So far it doesn't let me interact with it.
var h = new HTMLCollection(somevar);
I tried doing it with a constructor but it doesn't seem to have a constructor. I even tried with simple =
operator but no luck. Is there a quick and clean solution?
I've seen some solutions posted here like: create a HTMLCollection and I know I can't add to the collection as said here: How to add an element into the HTMLCollection in javascript?
In my case, I'm not trying to add to the collection but create a new one from a pre-existing variable.
EDIT:
My example:
var triplesingleslides = $(v)[0];
I'd like this triplesingleslides
to be HTMLCollection. Inside triplesingleslides
there are 3 div elements.
Why it's not a duplicate question:
It's asking if there is a simpler way to do it than those that already have complex answers and it would seem that there isn't, so this question is answered.